Your typical test code
Here’s some typical test code found in many codebases
This code suffers from several issues. Under what conditions is the tax rate calculated? What exactly is it doing? What is the expected outcome?
Being explicit with Spek
Spek makes it easy to define these three important aspects without resorting to long method names or underscores:
Tests are specifications
Tests are executable specifications of your system. They are real-time compilable code that tell you how a piece of code should behave and under what conditions is a certain outcome expected. That is why it is important to be explicit, concise and unambiguous when it comes to defining specifications. Spek helps you do that.
Spek works with Java
Spek is written in Kotlin and as such is 100% compatible with Java. You can write your specifications (notice we say specification, not test) in Kotlin and verify new or existing code written in Java or Kotlin.
Get Started Learn More