From 48c80e247ea3b85799bd4e2caaae0e07faebe19b Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Sat, 1 Dec 2018 07:27:27 +0300 Subject: [PATCH] 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 --- .../annotations-common/build.gradle | 1 + .../src/test/kotlin}/AnnotationsTest.kt | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) rename libraries/kotlin.test/{common/src/test/kotlin/kotlin/test/tests => annotations-common/src/test/kotlin}/AnnotationsTest.kt (53%) diff --git a/libraries/kotlin.test/annotations-common/build.gradle b/libraries/kotlin.test/annotations-common/build.gradle index 5988043c1b7..13d497a6172 100644 --- a/libraries/kotlin.test/annotations-common/build.gradle +++ b/libraries/kotlin.test/annotations-common/build.gradle @@ -9,6 +9,7 @@ configurePublishing(project) dependencies { compile project(':kotlin-stdlib-common') + testCompile project(":kotlin-test:kotlin-test-common") } pill { diff --git a/libraries/kotlin.test/common/src/test/kotlin/kotlin/test/tests/AnnotationsTest.kt b/libraries/kotlin.test/annotations-common/src/test/kotlin/AnnotationsTest.kt similarity index 53% rename from libraries/kotlin.test/common/src/test/kotlin/kotlin/test/tests/AnnotationsTest.kt rename to libraries/kotlin.test/annotations-common/src/test/kotlin/AnnotationsTest.kt index dd6e1340e36..319ac6e2009 100644 --- a/libraries/kotlin.test/common/src/test/kotlin/kotlin/test/tests/AnnotationsTest.kt +++ b/libraries/kotlin.test/annotations-common/src/test/kotlin/AnnotationsTest.kt @@ -8,32 +8,48 @@ package kotlin.test.tests import kotlin.test.* private var value = 5 +private var tests: MutableSet? = null class AnnotationsTest { @BeforeTest fun setup() { value *= 2 + assertNull(tests) + tests = mutableSetOf() } @AfterTest fun teardown() { value /= 2 + assertNotNull(tests).let { tests -> + assertNotEquals(emptySet(), tests) + } + tests = null + } + + private fun logTestRun(name: String) { + assertNotNull(tests).let { tests -> + assertEquals(emptySet(), 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) }