unit-tests: Rename annotations After/Before -> AfterEach/BeforeEach
This commit is contained in:
+3
-3
@@ -123,8 +123,8 @@ internal class TestProcessor (val context: KonanBackendContext): FileLoweringPas
|
||||
override val runtimeKindName: Name get() = throw NotImplementedError()
|
||||
},
|
||||
|
||||
BEFORE("kotlin.test.Before", "BEFORE"),
|
||||
AFTER("kotlin.test.After", "AFTER"),
|
||||
BEFORE_EACH("kotlin.test.BeforeEach", "BEFORE_EACH"),
|
||||
AFTER_EACH("kotlin.test.AfterEach", "AFTER_EACH"),
|
||||
BEFORE_CLASS("kotlin.test.BeforeClass", "BEFORE_CLASS"),
|
||||
AFTER_CLASS("kotlin.test.AfterClass", "AFTER_CLASS");
|
||||
|
||||
@@ -132,7 +132,7 @@ internal class TestProcessor (val context: KonanBackendContext): FileLoweringPas
|
||||
open val runtimeKindName = Name.identifier(runtimeKindString)
|
||||
|
||||
companion object {
|
||||
val INSTANCE_KINDS = listOf(TEST, BEFORE, AFTER)
|
||||
val INSTANCE_KINDS = listOf(TEST, BEFORE_EACH, AFTER_EACH)
|
||||
val COMPANION_KINDS = listOf(BEFORE_CLASS, AFTER_CLASS)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,10 @@ object TestRunner {
|
||||
override fun startSuite(suite: TestSuite) = println("Starting test suite: $suite")
|
||||
override fun endSuite(suite: TestSuite) = println("Test suite finished: $suite")
|
||||
|
||||
override fun start(testCase: TestCase) = println("Start test case: $testCase")
|
||||
override fun pass(testCase: TestCase) = println("Pass: $testCase")
|
||||
override fun start(testCase: TestCase) = println("Starting test case: $testCase")
|
||||
override fun pass(testCase: TestCase) = println("Passed: $testCase")
|
||||
override fun fail(testCase: TestCase, e: Throwable) {
|
||||
println("Fail: $testCase. Exception:")
|
||||
println("Failed: $testCase. Exception:")
|
||||
e.printStackTrace()
|
||||
}
|
||||
override fun ignore(testCase: TestCase) = println("Ignore: $testCase")
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package konan.test
|
||||
|
||||
import kotlin.AssertionError
|
||||
|
||||
interface TestCase {
|
||||
val name: String
|
||||
val suite: TestSuite
|
||||
@@ -14,8 +12,8 @@ interface TestSuite {
|
||||
}
|
||||
|
||||
enum class TestFunctionKind {
|
||||
BEFORE,
|
||||
AFTER,
|
||||
BEFORE_EACH,
|
||||
AFTER_EACH,
|
||||
BEFORE_CLASS,
|
||||
AFTER_CLASS
|
||||
}
|
||||
@@ -67,12 +65,12 @@ abstract class AbstractTestSuite<F: Function<Unit>>(override val name: String):
|
||||
|
||||
abstract class BaseClassSuite<INSTANCE, COMPANION>(name: String): AbstractTestSuite<INSTANCE.() -> Unit>(name) {
|
||||
|
||||
// These two methods are overrided in a test suite class generated by the compiler.
|
||||
// These two methods are overrided in test suite classes generated by the compiler.
|
||||
abstract fun createInstance(): INSTANCE
|
||||
open fun getCompanion(): COMPANION = throw NotImplementedError("Test class has no companion object")
|
||||
|
||||
companion object {
|
||||
val INSTANCE_KINDS = listOf(TestFunctionKind.BEFORE, TestFunctionKind.AFTER)
|
||||
val INSTANCE_KINDS = listOf(TestFunctionKind.BEFORE_EACH, TestFunctionKind.AFTER_EACH)
|
||||
val COMPANION_KINDS = listOf(TestFunctionKind.BEFORE_CLASS, TestFunctionKind.AFTER_CLASS)
|
||||
}
|
||||
|
||||
@@ -88,8 +86,8 @@ abstract class BaseClassSuite<INSTANCE, COMPANION>(name: String): AbstractTestSu
|
||||
return companionFunction.getOrPut(kind) { mutableSetOf() }
|
||||
}
|
||||
|
||||
val before: Collection<INSTANCE.() -> Unit> get() = getInstanceFunctions(TestFunctionKind.BEFORE)
|
||||
val after: Collection<INSTANCE.() -> Unit> get() = getInstanceFunctions(TestFunctionKind.AFTER)
|
||||
val before: Collection<INSTANCE.() -> Unit> get() = getInstanceFunctions(TestFunctionKind.BEFORE_EACH)
|
||||
val after: Collection<INSTANCE.() -> Unit> get() = getInstanceFunctions(TestFunctionKind.AFTER_EACH)
|
||||
|
||||
val beforeClass: Collection<COMPANION.() -> Unit> get() = getCompanionFunctions(TestFunctionKind.BEFORE_CLASS)
|
||||
val afterClass: Collection<COMPANION.() -> Unit> get() = getCompanionFunctions(TestFunctionKind.AFTER_CLASS)
|
||||
@@ -124,8 +122,8 @@ class TopLevelSuite(name: String): AbstractTestSuite<TopLevelFun>(name) {
|
||||
private val specialFunctions = mutableMapOf<TestFunctionKind, MutableSet<TopLevelFun>>()
|
||||
private fun getFunctions(type: TestFunctionKind) = specialFunctions.getOrPut(type) { mutableSetOf() }
|
||||
|
||||
val before: Collection<TopLevelFun> get() = getFunctions(TestFunctionKind.BEFORE)
|
||||
val after: Collection<TopLevelFun> get() = getFunctions(TestFunctionKind.AFTER)
|
||||
val before: Collection<TopLevelFun> get() = getFunctions(TestFunctionKind.BEFORE_EACH)
|
||||
val after: Collection<TopLevelFun> get() = getFunctions(TestFunctionKind.AFTER_EACH)
|
||||
val beforeClass: Collection<TopLevelFun> get() = getFunctions(TestFunctionKind.BEFORE_CLASS)
|
||||
val afterClass: Collection<TopLevelFun> get() = getFunctions(TestFunctionKind.AFTER_CLASS)
|
||||
|
||||
|
||||
@@ -4,23 +4,25 @@ package kotlin.test
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class Test
|
||||
|
||||
// Not supported in Kotlin/Common
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class BeforeClass
|
||||
|
||||
// Not supported in Kotlin/Common
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class AfterClass
|
||||
|
||||
// TODO: Rename Before -> BeforeEach, After -> AfterEach
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class Before
|
||||
annotation class BeforeEach
|
||||
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.FUNCTION)
|
||||
annotation class After
|
||||
annotation class AfterEach
|
||||
|
||||
// TODO: Support.
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
|
||||
annotation class Ignore
|
||||
|
||||
Reference in New Issue
Block a user