Working with code V003
V003 - Tests discarded during validation
The output code V003 indicates that tests were discarded during the validation stage where the created tests are run in a realistic test environment. The possible causes of V003 differ depending upon the state of your test suite before running Diffblue Cover CLI Cover.
Test suite fails before created tests are added
Before creating tests using Cover, ensure that the existing test suite can be run and all tests pass via the Maven or Gradle test commands. If the test suite can't be run successfully at this stage then it's probable that many or all tests generated by Cover will be discarded during validation. Resolve failing tests before running Cover on the project.
Test suite passes before created tests are added
If your current test suite passes before running dcover create
and you encounter the V003 output code, check the following possible causes. Otherwise, please contact Diffblue Support for help.
Dependence upon shared mutable state
For tests that rely upon shared mutable state, it is possible for that state to get set in a different way in the true test environment compared to when the test is run by Cover's internal checks. Please ensure that any shared mutable state upon which the classes used in the failing tests depend is correctly set in the arrange section of those tests.
Alternately, try running Cover, to generate tests for only the problematic classes with prefix filtering, e.g. dcover create com.example.problematicpackage com.example.ProblematicClass
. Sometimes this will allow the state to be set correctly in the generated tests.
Style checking/linting failures
Cover does not guarantee that tests it produces obey the required styles for the project. Run Cover with --ignore-stylechecks
, disable style checking/linting for Cover generated test files or manually edit the produced tests to align with your style rules.
Last updated