When I execute this BehaviorSpec, the upper when block always fails (even when I swap those two). the upper block assignment is always overridden by the latter. Is this an issue or I just misunderstand spec flow?
given("user) {
val user = User()
`when`("set valid email") {
user.email = VALID_EMAIL
then("should get correct email") {
user.email shouldBe VALID_EMAIL
}
}
`when`("set null email") {
user.email = null
then("should get null email") {
user.email shouldBe null
}
}
Do you use any config on the test, or exactly as you showed there.
The issue is, the when block has to be executed in order to discover the then block nested inside. However, this means the side effects (setting user.email) overwrite each other.
So it sounds violate the BDD concept, when blocks should not affect each another. Hope this will be fixed soon! Thanks.
This is fixed in 3.0.0 RC1.
If you have the time, please give it a try. There are some breaking changes that should be aware of by reading the changelog here: https://github.com/kotlintest/kotlintest/blob/master/CHANGELOG.md
Thanks @sksamuel . I'm trying it right now! :D