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:
Ilya Gorbunov
2018-12-01 07:27:27 +03:00
parent 4a828f839f
commit 48c80e247e
2 changed files with 18 additions and 1 deletions
@@ -9,6 +9,7 @@ configurePublishing(project)
dependencies {
compile project(':kotlin-stdlib-common')
testCompile project(":kotlin-test:kotlin-test-common")
}
pill {
@@ -8,32 +8,48 @@ package kotlin.test.tests
import kotlin.test.*
private var value = 5
private var tests: MutableSet<String>? = null
class AnnotationsTest {
@BeforeTest
fun setup() {
value *= 2
assertNull(tests)
tests = mutableSetOf()
}
@AfterTest
fun teardown() {
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
fun testValue() {
assertEquals(10, value)
logTestRun("testValue")
}
@Test
fun testValueAgain() {
assertEquals(10, value)
logTestRun("testValueAgain")
}
@Ignore
@Test
fun testValueWrong() {
fun testValueWrongIgnored() {
assertEquals(20, value)
}