Structure Unit Testing with Spek
summary
Spek is a Kotlin testing DSL that runs on the JUnit 5 engine and supports Android with a dedicated IDE plugin and Jacoco coverage. It provides memoized delegate fixtures that create new instances per test by default and a configurable caching mode: test or eachGroup to share instances across scopes. Two styles exist, spec (describe/context/it) and Gherkin like (given/when/then), with caveats: discovery runs group code, given/when count as tests, and failing Gherkin blocks stop nested execution. It works but requires careful fixture placement.
AI-written summary · about
chapters (21)
- 0:00Introduction and speaker background
- 1:16Talk overview and audience check
- 2:34Problems with traditional JUnit tests
- 5:42Introduction to Spek framework
- 6:45Setting up Spek in a project
- 7:27Basic test structure in Spek
- 9:57Test execution phases in Spek
- 10:40Fixtures and test setup
- 12:48Property isolation with memoized delegates
- 15:33Writing parameterized tests
- 16:14Running Spek tests in IDEs
- 17:17Specification style in Spek
- 18:46Example test case walkthrough
- 20:31Mocking and test behavior setup
- 21:34Skipping tests in Spek
- 23:03Gherkin style in Spek
- 24:06Gherkin example and output
- 25:54Gherkin style limitations
- 28:43Pros and cons of Spek styles
- 30:31Best practices for using Spek
- 30:51Resources and closing
related talks
29mWrite Unit Tests with Spek
49mTesting Kotlin at Scale: Spek
30mGet a Cool Unit Test Environment with Spek2 + MockK + JaCoCo
32mTesting with Kotlin
18mSpeedup unit testing with the Spock framework
01h 12mUnit Tests as a Specification
25mIdiomatic Kotlin in Tests
01h 29mIntro to unit testing coroutines with Kotest & MockK
