NOV. 15 – 18, 2021

Property-based Testing with Java

Johannes Link

What is Property-based Testing and how does it compliment example tests

Jqwik as a reasonable library to do PBT on the JVM

The value of shrinking for PBT

Patterns to find good properties

Combining PBT with example tests


Property-based Testing with Java

More thorough tests with less code

PBT is not only suitable for functional languages but also works in traditional OOP.

Test-driven Development in OO languages —as mostly taught today — focuses on example-based test cases, which can easily be written with JUnit or similar tools. However, when looking on functional languages like Haskell or F# you often stumble open something different: property tests.

Property tests are based on the idea to specify intended properties of our code, and to let the testing library create and execute test cases that try to falsify those properties. In this workshop I will both explain the theory behind Property-Based Testing and show how to implement it with Java. Participants will be given the opportunity to make hands-on experiments using Jqwik, a PBT library implemented as JUnit 5 test engine.

If you like AgileTD you might also be interested in :