dave08
04/18/2021, 2:26 PMsam
04/18/2021, 2:27 PMdave08
04/18/2021, 2:28 PMgiven {
}.and {
}.when {
}.and {
sam
04/18/2021, 2:30 PMdave08
04/18/2021, 2:31 PMsam
04/18/2021, 2:32 PMdave08
04/18/2021, 2:32 PMsam
04/18/2021, 2:33 PMdave08
04/18/2021, 2:33 PMsam
04/18/2021, 2:33 PMdave08
04/18/2021, 2:35 PMsam
04/18/2021, 2:38 PMdave08
04/18/2021, 2:38 PMsam
04/18/2021, 2:38 PMval fixture = ...
given("qweqwe") {
}
when("qeqw") {
}
then("werewr") {
}
dave08
04/18/2021, 2:39 PMresult
, and a provided one in the given for setting some fixture objects...
given("qweqwe") { // 'this' is a GivenContext with a var for fixtures
fixture[1] = RepoStub()
fixture[0] = SutClass(fixture[1])
}
when("qeqw") { // 'this' is a WhenContext with the fixtures in GivenContext and a result var
result = fixture[0].methodUnderTest()
}
then("werewr") { // 'this' has all the above
result shouldBe fixture[1].stubValue
}
maybe something like this?fixture[0]
and fixture[1]
might not be so nice, though, but there might be better ways.sam
04/18/2021, 2:49 PMdave08
04/18/2021, 2:50 PMsam
04/18/2021, 2:56 PMchristophsturm
04/18/2021, 5:28 PMdave08
04/19/2021, 9:59 AMgiven
line or a bunch of nested `and`s gets pretty messy.
This proposition wouldn't be a replacement for the current BehaviourSpec, but rather an optional addition to it... @christophsturmchristophsturm
04/19/2021, 10:02 AMsam
04/19/2021, 10:03 AMdave08
04/19/2021, 10:06 AMchristophsturm
04/19/2021, 10:09 AMdave08
04/19/2021, 10:10 AMsam
04/19/2021, 10:10 AMchristophsturm
04/19/2021, 10:12 AMsam
04/19/2021, 10:13 AMchristophsturm
04/19/2021, 10:14 AMsam
04/19/2021, 10:14 AMdave08
04/19/2021, 10:15 AMsam
04/19/2021, 10:15 AMdave08
04/19/2021, 10:15 AMsam
04/19/2021, 10:15 AMdave08
04/19/2021, 10:16 AMsam
04/19/2021, 10:16 AMchristophsturm
04/19/2021, 10:16 AMsam
04/19/2021, 10:16 AMchristophsturm
04/19/2021, 10:16 AMsam
04/19/2021, 10:18 AMchristophsturm
04/19/2021, 10:19 AMsam
04/19/2021, 10:20 AMchristophsturm
04/19/2021, 10:20 AMsam
04/19/2021, 10:21 AMchristophsturm
04/19/2021, 10:22 AMclass UserService : RestService {
suspend fun create(user: User): User {
delay(1)
return user.copy(id = "userId")
}
suspend fun show(userId: Int): User {
delay(1)
return User(id = userId.toString(), name = "User $userId")
}
}
that fits 99% of the code that i write and makes it really easy to testsam
04/19/2021, 10:23 AMchristophsturm
04/19/2021, 10:23 AMsam
04/19/2021, 10:24 AMchristophsturm
04/19/2021, 10:24 AMsam
04/19/2021, 10:26 AMchristophsturm
04/19/2021, 10:27 AMsam
04/19/2021, 10:28 AMchristophsturm
04/19/2021, 10:28 AMsam
04/19/2021, 10:29 AMchristophsturm
04/19/2021, 10:30 AMsam
04/19/2021, 10:31 AMchristophsturm
04/19/2021, 10:32 AMsam
04/19/2021, 10:35 AMchristophsturm
04/19/2021, 10:37 AMsam
04/19/2021, 10:39 AMchristophsturm
04/19/2021, 10:39 AMsam
04/19/2021, 10:40 AMchristophsturm
04/19/2021, 10:40 AMsam
04/19/2021, 10:40 AMchristophsturm
04/19/2021, 10:42 AMsam
04/19/2021, 10:42 AMchristophsturm
04/19/2021, 10:43 AMsam
04/19/2021, 10:43 AMchristophsturm
04/19/2021, 10:43 AMsam
04/19/2021, 10:44 AMchristophsturm
04/19/2021, 10:44 AMsam
04/19/2021, 10:47 AMchristophsturm
04/19/2021, 10:58 AMsam
04/19/2021, 10:59 AMchristophsturm
04/19/2021, 10:59 AMsam
04/19/2021, 11:01 AMimplementation
thing doesn't seem super robustchristophsturm
04/19/2021, 11:01 AMsam
04/19/2021, 11:03 AMchristophsturm
04/19/2021, 11:04 AMsam
04/19/2021, 11:04 AMKotestEngineLauncher()
.withSpec(DummySpec1::class)
.withSpec(DummySpec2::class)
.launch()
christophsturm
04/19/2021, 11:15 AMsam
04/19/2021, 11:16 AMchristophsturm
04/19/2021, 11:18 AMsam
04/19/2021, 11:18 AMchristophsturm
04/19/2021, 11:19 AMsam
04/19/2021, 11:20 AMchristophsturm
04/19/2021, 11:20 AMsam
04/19/2021, 11:22 AMchristophsturm
04/19/2021, 11:22 AMsam
04/19/2021, 11:23 AM"Test".config(timeout = 300.milliseconds) {
Thread.sleep(100)
}
christophsturm
04/19/2021, 11:23 AMsam
04/19/2021, 11:23 AM"Test 2".config(timeout = 300.milliseconds) {
Thread.sleep(500) // should fail
}
christophsturm
04/19/2021, 11:24 AMsam
04/19/2021, 11:25 AM"Test".config(timeout = 5.milliseconds) {
Thread.sleep(4)
}