Unit-Testing Overview
Modddels come with a simplified way to unit-test them.
Let's say you have an Age
ValueObject you want to unit-test. First, in the @Modddel
annotation, set generateTestClasses
to true :
This will generate two classes :
TestAge
: This is what we call the "Tester". It allows you to create tests.AgeParams
: This is what we call the "ModddelParams". It represents the parameters of the modddel.
Now, in your unit-test file, you can start adding some tests this way :
As you can see :
You create an instance of the Tester
Optionally, you can group your tests in
group
methodsYou add your tests. In this example, we created two tests : the first one verifies that the
Age
is valid when given19
as an argument, and the second20
.
Last updated