Creating skeleton tests
Skeleton tests simply consist of a call to the method under test, with all variables initialized to null
or zero, and some comments reminding the user to better populate the "arrange" section and come up with some assertions. They are intended as a helpful starting point for users to write their own tests.
There are two ways of obtaining a skeleton test for a method in Diffblue Cover:
Skeleton tests are intentionally written with all available comments to aid readability, and minimal inlining to ease editing, which means that all test formatting options will be superseded.
For example, consider the method in the following inner class in an outer class, DatabaseDao
:
Diffblue Cover is unable to test this by default as there doesn't appear to be a way of creating an instance of Inner
on which to call myMethod(Inner)
, and so this results in an R008
output code with some explanation why a full test could not be written. Rather than provide just the output code, Diffblue Cover will offer a skeleton test for the method as follows:
This skeleton test serves as a helpful illustration of the output code, allowing you to play with your code and better understand why testing the method is difficult, and what could be changed to make it easier. In other cases you will know a way of obtaining an instance to test with, in which case you are well placed to complete the test by hand, choosing useful values for the variables and adding relevant assertions. Alternatively, you may want to "teach" Diffblue Cover how to create useful instances via Custom Inputs.
Last updated