JUnit • Introduction of Spek • Project set-up • Core principles • How to write a test ( 2 distinct styles) • Specification • Gherkin • Wrap up & Questions
• Top down build test three • Execute code in groups • Top down execution of • Registered fixtures for scopes (setup/teardown case) • Tests (assertions)
- executable specification • Most of the lines start with a special keyword • Feature, Scenario, Given, When , Then, And • Keywords are translated to multiple languages
Guess the word # The first example has two steps Scenario: Maker starts a game When the Maker starts a game Then the Maker waits for a Breaker to join # The second example has three steps Scenario: Breaker joins a game Given the Maker has started a game with the word "silky" When the Breaker joins the Maker's game Then the Breaker must guess a word with 5 characters
so flexible regarding nesting • Default caching mode EACH_SCOPE -> test are not isolated ->if one test fails, its over • No build in mechanism for skipping • Given/When acts as a test in output and counts as a test
are easy to read -> understand -> review • Reusability made easy (memoized) • Write parametrised tests as normal Kotlin code • Not so many options as JUnit 5 to fine tune • Specification vs Gherkin • Can exist alongside existing JUnit tests -> give it a shot
• println(…) is your friend • never interact with property outside of before/after..{…} • one assertion per test( it{…},Then{…}, And{…} ) • use test{…} only for assertions