question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Q] Is BehaviorSpec Given block executed for each test?

See original GitHub issue

With:

Given("a duck") {

    val duck= Duck()

    When("it quacks") {
        Then("it makes noise") {
            ..
        }
    }

    When("it walks") {
        Then("it moves") {
            ..
        }
    }
}

Is the duck instance (re-)created for each test? I need to create a new instance per test and I wonder it is correct behavior to use the Given block instead of the beforeTest fun?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
marceloverdijkcommented, Dec 20, 2019

Yes, thx for your swift replies!

1reaction
LeoColmancommented, Dec 20, 2019

Is BehaviorSpec Given block executed for each test?

Depends on your IsolationMode. Check more documentation here.

What you should do to ensure Given is executed each time a test is executed, you should use IsolationMode.InstancePerTest or perhaps IsolationMode.InstancePerLeaf

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Q] Is BehaviorSpec Given block executed for each test? #1130
I need to create a new instance per test and I wonder it is correct behavior to use the Given block instead of...
Read more >
Testing Styles - Kotest
Kotest offers 10 different styles of test layout. Some are inspired from other popular test frameworks to make you feel right at home....
Read more >
kotlin - KotlinTest`s BehaviorSpec "No runnable methods" with ...
I know that the problem is that I am trying to run a test written with KotlinTest with Spring, but how can I...
Read more >
GivenWhenThen - Martin Fowler
The essential idea is to break down writing a scenario (or test) into three sections: The given part describes the state of the...
Read more >
https://raw.githubusercontent.com/kotlintest/kotli...
**Note:** All packages are now `io.kotest` instead of `io.kotlintest`. ... **Test Framework**<br/>Layout tests in a fluid way and execute them on the JVM...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found