Move kotlin.test common annotations tests
Place them in tests of kotlin-test-annotations-common, so that every platform module that implements that common module (e.g. kotlin-test-junit, kotlin-test-junit5, kotlin-test-testng) gets these tests run. Improve test for BeforeTest/AfterTest annotations to check that they are invoked before/after _each_ test method. #KT-27629
This commit is contained in:
@@ -9,6 +9,7 @@ configurePublishing(project)
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':kotlin-stdlib-common')
|
compile project(':kotlin-stdlib-common')
|
||||||
|
testCompile project(":kotlin-test:kotlin-test-common")
|
||||||
}
|
}
|
||||||
|
|
||||||
pill {
|
pill {
|
||||||
|
|||||||
+17
-1
@@ -8,32 +8,48 @@ package kotlin.test.tests
|
|||||||
import kotlin.test.*
|
import kotlin.test.*
|
||||||
|
|
||||||
private var value = 5
|
private var value = 5
|
||||||
|
private var tests: MutableSet<String>? = null
|
||||||
|
|
||||||
class AnnotationsTest {
|
class AnnotationsTest {
|
||||||
|
|
||||||
@BeforeTest
|
@BeforeTest
|
||||||
fun setup() {
|
fun setup() {
|
||||||
value *= 2
|
value *= 2
|
||||||
|
assertNull(tests)
|
||||||
|
tests = mutableSetOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
@AfterTest
|
@AfterTest
|
||||||
fun teardown() {
|
fun teardown() {
|
||||||
value /= 2
|
value /= 2
|
||||||
|
assertNotNull(tests).let { tests ->
|
||||||
|
assertNotEquals(emptySet<String>(), tests)
|
||||||
|
}
|
||||||
|
tests = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun logTestRun(name: String) {
|
||||||
|
assertNotNull(tests).let { tests ->
|
||||||
|
assertEquals(emptySet<String>(), tests)
|
||||||
|
tests.add(name)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testValue() {
|
fun testValue() {
|
||||||
assertEquals(10, value)
|
assertEquals(10, value)
|
||||||
|
logTestRun("testValue")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testValueAgain() {
|
fun testValueAgain() {
|
||||||
assertEquals(10, value)
|
assertEquals(10, value)
|
||||||
|
logTestRun("testValueAgain")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore
|
@Ignore
|
||||||
@Test
|
@Test
|
||||||
fun testValueWrong() {
|
fun testValueWrongIgnored() {
|
||||||
assertEquals(20, value)
|
assertEquals(20, value)
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user