Hinaka
10/21/2021, 3:47 PMclass TestClass {
private val testDispatcher = TestCoroutineDispatcher()
@Before
fun setup() {
// provide the scope explicitly, in this example using a constructor parameter
Dispatchers.setMain(testDispatcher)
}
@After
fun cleanUp() {
Dispatchers.resetMain()
testDispatcher.cleanupTestCoroutines()
}
@Test
fun testFoo() = testDispatcher.runBlockingTest {
// TestCoroutineDispatcher.runBlockingTest uses `testDispatcher` to run coroutines
foo()
}
}
fun foo() {
MainScope().launch {
// launch will use the testDispatcher provided by setMain
}
}
and inject that testDispatcher
to any class that need a dispatcher. Can I do the same using kotest, especially with the BehaviorSpec
?nikolaymetchev
10/22/2021, 10:09 AMLeoColman
10/23/2021, 6:08 PMdave08
10/25/2021, 10:25 AMdave08
10/25/2021, 10:27 AM> Task :api:kotest
io.kotest.engine.reporter.TaycanConsoleReporter
java.lang.ClassNotFoundException: io.kotest.engine.reporter.TaycanConsoleReporter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:315)
at io.kotest.engine.launcher.ConsoleKt.createConsoleListener(console.kt:21)
at io.kotest.engine.launcher.MainKt.main(main.kt:28)
christophsturm
10/25/2021, 10:30 AMSandymcp
10/25/2021, 3:11 PMpackage sse
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import java.io.BufferedReader
import java.io.StringReader
data class Case<G, W>(val given: G, val want: W)
class SseReaderKoTest : FunSpec({
context("read tag and payload test") {
withData(
mapOf(
"empty marks end of message" to Case("\n", "" to ""),
"event and payload" to Case("event: surprise\n", "event" to "surprise"),
"data and payload" to Case("data: surprise\n", "data" to "surprise"),
"id and payload" to Case("id: surprise\n", "id" to "surprise"),
"comment" to Case(": surprise\n", ":" to ""),
"blank comment" to Case(":\n", ":" to ""),
)
) { (given, want) ->
readTagAndPayload(BufferedReader(StringReader(given))) shouldBe want
}
}
})
Sangmin Lee
10/26/2021, 7:08 AMBig Chungus
11/01/2021, 3:48 PMdave08
11/02/2021, 3:20 PMsam
11/02/2021, 3:24 PMImran/Malic
11/03/2021, 1:22 PMArb<A>.distinct()
in 5.0.0.X
Emil Kantis
11/04/2021, 9:59 AMx
is not null in this case? Perhaps a specific shouldNotBeNull
matcher required?
var x: String? = "hello"
x shouldNotBe null
x!!.substring(2) shouldBe "he" // !! should not be necessary, since previous assertion checks that it is not null
Big Chungus
11/04/2021, 10:32 AMIvan Pavlov
11/07/2021, 8:03 AMLilly
11/09/2021, 3:12 PMPratik Tandel
11/10/2021, 8:46 PMJulian Ostarek
11/14/2021, 5:51 PMcharleskorn
11/14/2021, 8:30 PMPeter
11/15/2021, 3:23 AM'java.lang.Throwable io.kotest.assertions.eq.EqKt.eq$default(java.lang.Object, java.lang.Object, boolean, int, java.lang.Object)'
java.lang.NoSuchMethodError: 'java.lang.Throwable io.kotest.assertions.eq.EqKt.eq$default(java.lang.Object, java.lang.Object, boolean, int, java.lang.Object)'
this happens when i do x().shouldBeSome("y")
❌
kotest 4.6.3
io.kotest.extensions:kotest-assertions-arrow:1.1.1simon.vergauwen
11/17/2021, 8:01 PMJavier
11/17/2021, 10:20 PMsimon.vergauwen
11/18/2021, 8:01 AM5.0.0.RC
for Kotest and Gradle plugin.
https://github.com/nomisRev/Saga/runs/4248416261?check_suite_focus=true#step:4:59Michael Strasser
11/18/2021, 8:32 AMwithData
and DescribeSpec
but I can’t get the tests to be named as I expect.
Given a function fun messageMap(id: String): Map<String, Message>
that returns 3 different messages, if I use:
describe("adds messages") {
val id = randomId()
it("sets ID from message") {
withData(messageMap(id)) { message ->
Builder.newInstance().addMessage(message).getId() shouldBe id
}
}
}
The test runs once with title “sets ID from message”. But if I use:
describe("adds messages") {
val id = randomId()
withData(messageMap(id)) { message ->
it("sets ID from message") {
Builder.newInstance().addMessage(message).getId() shouldBe id
}
}
}
The test runs 3 times with titles:
sets ID from message
(1) sets ID from message
(2) sets ID from message
I expected from the docs that the string keys for the map would be used as test names.
I am using Kotest 4.6.3.Didier Villevalois
11/20/2021, 11:36 AMcommonTest
source-set:
implementation("io.kotest:kotest-framework-engine:$kotestVersion")
implementation("io.kotest:kotest-framework-datatest:$kotestVersion")
I also had to add this dependencies to my jvmTest
source-set, to have the tests picked up by JUnit:
implementation("io.kotest:kotest-runner-junit5:$kotestVersion")
1. What are the corresponding ways to have tests picked up for JS and Native targets?
2. It seems to me that kotest-framework-datatest
is not yet supported on Native target? (cf. https://search.maven.org/search?q=g:io.kotest%20kotest-framework-datatest) Will this be supported at some point? (I don't seem to see anything in its source code https://github.com/kotest/kotest/tree/master/kotest-framework/kotest-framework-datatest that would prevent it from running on Native, except the fact that the target is not defined in the Gradle build file. Or am I missing something?)Didier Villevalois
11/20/2021, 12:47 PMwithData
) with a specific timeout.Rob Elliot
11/24/2021, 4:39 PMkotest-extensions-spring:1.0.1
to my maven project (using surefire to run kotest-framework-api-jvm:4.6.3
) and with no code changes it stopped finding any of my existing specs. No errors logged, it just silently stops working.Lilly
11/24/2021, 4:43 PMsam
11/24/2021, 6:48 PMthanksforallthefish
11/25/2021, 8:34 AMthanksforallthefish
11/25/2021, 8:34 AMEmil Kantis
11/25/2021, 8:36 AMthanksforallthefish
11/25/2021, 8:41 AMsam
11/25/2021, 12:11 PMEmil Kantis
11/25/2021, 2:54 PMthanksforallthefish
11/25/2021, 2:54 PM