-
Notifications
You must be signed in to change notification settings - Fork 623
/
PropListenersTest.kt
126 lines (115 loc) · 2.88 KB
/
PropListenersTest.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.sksamuel.kotest.property
import io.kotest.core.spec.style.FunSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import io.kotest.property.*
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.string
class PropListenersTest : FunSpec({
var previous = -1
var current = 0
var total = 0
beforeTest {
previous = -1
current = 0
total = 0
}
val propConfig = PropTestConfig(listeners = listOf(object : PropTestListener {
override suspend fun beforeTest() {
previous = current
++current
}
override suspend fun afterTest() {
++total
}
}))
test("checkAll calls listener for param A") {
val context = checkAll(10, propConfig, Arb.string()) {
current shouldBe (previous + 1)
total shouldBe previous
}
previous shouldBe 9
current shouldBe 10
total shouldBe 10
}
test("checkAll calls listener for params A, B") {
val context = checkAll(
10,
propConfig,
Arb.string(),
Arb.int()
) { _, _ ->
current shouldBe (previous + 1)
total shouldBe previous
}
previous shouldBe 9
current shouldBe 10
total shouldBe 10
}
test("checkAll calls listener for params A, B, C") {
val context = checkAll(
10,
propConfig,
Arb.string(),
Arb.string(),
Arb.int()
) { _, _, _ ->
current shouldBe (previous + 1)
total shouldBe previous
}
previous shouldBe 9
current shouldBe 10
total shouldBe 10
}
test("checkAll calls listener for params A, B, C, D") {
val context = checkAll(
10,
propConfig,
Arb.string(),
Arb.int(),
Arb.string(),
Arb.int()
) { _, _, _, _ ->
current shouldBe (previous + 1)
total shouldBe previous
}
previous shouldBe 9
current shouldBe 10
total shouldBe 10
}
test("checkAll calls listener for params A, B, C, D, E") {
val context = checkAll(
10,
propConfig,
Arb.string(),
Arb.int(),
Arb.string(),
Arb.string(),
Arb.int()
) { _, _, _, _, _ ->
current shouldBe (previous + 1)
total shouldBe previous
}
previous shouldBe 9
current shouldBe 10
total shouldBe 10
}
test("checkAll calls listener for params A, B, C, D, E, F") {
val context = checkAll(
10,
propConfig,
Arb.string(),
Arb.int(),
Arb.string(),
Arb.int(),
Arb.string(),
Arb.int()
) { _, _, _, _, _, _ ->
current shouldBe (previous + 1)
total shouldBe previous
}
previous shouldBe 9
current shouldBe 10
total shouldBe 10
}
})