Like the title says, is there a way to specify a test without the @Test annotation? I took a look at the JS code for Kotlin Test and it seems fairly easy to define you own framework adapter. However, I’m trying to actually create some functionality to write the tests in a different format such as gherkin or jasmine rather than convert the regular junit style to one of those. I didn’t see any annotation processor that would hint to how that annotation funnels the data into the method
@JsName(“test”)
internal fun test(name: String, ignored: Boolean, testFn: () → Unit)
I found a way to create the tests without the annotation and they work.
Very quick and dirty:
@JsModule(“kotlin-test”)
external val kTest:dynamic
kTest.kotlin.test.suite("package test", false){
kTest.kotlin.test.suite("suit test", false) {
kTest.kotlin.test.test("test", false) {
assertTrue(true)
}
}
}
But not perfect yet since karma seems to have the counts a bit messed up. I had 4 test before adding this code and then it went to 6 tests out of 4.
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 0 of 4 SUCCESS (0 secs / 0 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 1 of 4 SUCCESS (0 secs / 0.005 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 2 of 4 SUCCESS (0 secs / 0.006 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 3 of 4 SUCCESS (0 secs / 0.009 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 4 of 4 SUCCESS (0 secs / 0.01 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 5 of 4 SUCCESS (0 secs / 0.01 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 6 of 4 SUCCESS (0 secs / 0.01 secs)
HeadlessChrome 72.0.3617 (Windows 10.0.0): Executed 6 of 4 SUCCESS (0.105 secs / 0.01 secs)
Making the test class an object gets rid of the additional duplicate tests generated by the code above
For anyone finding this thread in the future, the YouTrack ticket is https://youtrack.jetbrains.com/issue/KT-46899