/
IsolationTest.kt
68 lines (54 loc) · 2.99 KB
/
IsolationTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.sksamuel.kotest.runner.jvm
import com.nhaarman.mockito_kotlin.*
import io.kotest.core.spec.description
import io.kotest.core.spec.style.WordSpec
import io.kotest.core.engine.IsolationTestEngineListener
import io.kotest.core.engine.TestEngineListener
class IsolationTestEngineListenerTest : WordSpec({
"IsolationTestEngineListener" should {
"only notify for the running test" {
val mock = mock<TestEngineListener> {}
val listener = IsolationTestEngineListener(mock)
val spec1 = IsolationTestSpec1()
val spec2 = IsolationTestSpec2()
val spec3 = IsolationTestSpec3()
listener.specStarted(spec1::class)
listener.specInstantiated(spec1)
listener.specInstantiated(spec2)
listener.specInstantiated(spec3)
then(mock).should()
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationTestSpec1" })
then(mock).should(never())
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationTestSpec2" })
then(mock).should(never())
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationIsolationTestSpec3" })
}
"run queued callbacks for a single next spec when current spec completes" {
val mock = mock<TestEngineListener> {}
val listener = IsolationTestEngineListener(mock)
val spec1 = IsolationTestSpec1()
val spec2 = IsolationTestSpec2()
val spec3 = IsolationTestSpec3()
listener.specStarted(spec1::class)
listener.specInstantiated(spec1)
listener.specStarted(spec2::class)
listener.specInstantiated(spec2)
listener.specFinished(spec3::class, null, emptyMap())
then(mock).should().specStarted(argThat { this.simpleName == spec1::class.simpleName })
then(mock).should()
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationTestSpec1" })
then(mock).should(never())
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationTestSpec2" })
listener.specFinished(spec1::class, null, emptyMap())
then(mock).should().specFinished(argThat { this.simpleName == spec1::class.simpleName }, anyOrNull(), any())
then(mock).should().specStarted(argThat { this.simpleName == spec2::class.simpleName })
then(mock).should()
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationTestSpec2" })
then(mock).should(never())
.specInstantiated(argThat { this::class.description().fullName() == "com.sksamuel.kotest.runner.jvm.IsolationTestSpec3" })
}
}
})
class IsolationTestSpec1 : WordSpec()
class IsolationTestSpec2 : WordSpec()
class IsolationTestSpec3 : WordSpec()