Writing unit tests with Cover CLI
A quick guide to writing unit tests for the single-module Maven project,
spring-petclinic, using the Cover CLI.
spring-petlinic application can be found at https://github.com/spring-projects/spring-petclinic
git clone https://github.com/spring-projects/spring-petclinic
Compile the project
Writing new tests
In order to create a new set of tests with
dcover use the
For example, running the following command from the root of the
will produce tests for all accessible functions within the project. By default, tests will be stored in files called
ClassNameDiffblueTest. If these files already exist, by default they will be replaced when the command is invoked again.
If you prefer to save the tests to a location other than
src/test/java, use the
dcover create --test-output-dir=src/test/diffblue
Note that, for multi-module projects, it is required to be able to compile the individual module and to run the
dcover command within the module directory (not at the root of a multi-module project)
For additional optional arguments and examples, please refer to the Cover CLI Usage guide.