Strange "Behavior Spec" behavior
See original GitHub issueHello. I tried the last 2.0-SNAPSHOT of kotlinspec (built from this commit). I have next code:
class Test : BehaviorSpec() {
init {
Given("test") {
When("when 1") {
println("when 1")
Then("test 1") {
println("test 1")
}
Then("test 2") {
println("test 2")
}
}
When("when 2") {
println("when 2")
Then("test 3") {
println("test 3")
}
Then("test 4") {
println("test 4")
}
}
}
}
}
And there are outputs:
oneInstancePerTest = true | oneInstancePerTest = false
when 1 | when 1
when 2 | when 2
when 1 | test 1
when 2 | test 2
test 1 | test 3
when 1 | test 4
when 2
test 2
when 1
when 2
test 3
when 1
when 2
test 4
May I am wrong, but I think when
block must be running separately just for inner then
block:
when 1 -> test 1 -> test 2
when 2 -> test 3 -> test 4
so I can write something like that:
Given(a user try to login)
When(login was failed) // mock request, configured via Mockito, returns error, valid for this `when` block
Then(show error for user)
When(login is success) // the same mock request returns success, valid for this `when` block
Then(store auth token)
Then(redirects user to main)
Issue Analytics
- State:
- Created 7 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Strange "Behavior Spec" behavior · Issue #163 - GitHub
Hello. I tried the last 2.0-SNAPSHOT of kotlinspec (built from this commit). I have next code: class Test : BehaviorSpec() { init ...
Read more >Strange Behavior (1981) - Technical Specifications - IMDb
Technical Specifications ; Runtime, 1 hr 39 min (99 min) 1 hr 45 min (105 min) (New Zealand) 1 hr 27 min (87...
Read more >ADHD and Disruptive Behavior Disorders - CHADD
Having ADHD along with a coexisting disruptive behavior disorder (ODD/CD) can complicate diagnosis and treatment and also worsen the prognosis.
Read more >Oppositional Defiant Disorder (ODD): Symptoms & Treatment
Anger and irritability. Argumentative and defiant behavior. · Lose their temper easily. Have frequent outbursts of anger and resentment.
Read more >Behavioural disorders in children - Better Health Channel
The most common disruptive behaviour disorders include oppositional defiant disorder (ODD), conduct disorder (CD) and attention deficit hyperactivity disorder ( ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The problem might be related to this: When I used interceptors to do setup work before the tests were run, I noticed that code in the
Given
andWhen
blocks is executed before the spec interceptor is called.Test setup:
Result:
IMO the spec interceptor should be called before any code in a given, when or then block is executed.
I think oneInstancePerTest affects things, but isn’t the root cause. I’m looking into it.