R - Reason Codes
Last updated
Was this helpful?
Last updated
Was this helpful?
These output codes are associated with checks performed on your Java code by Diffblue Cover and highlight code issues that prevent tests being created.
There are no fields that could be asserted on. Add getters or make the fields package-private.
Please check that the class is available on your test runtime classpath. See
A static initializer threw an exception while trying to load a class. Make sure static initializers can be executed without throwing exceptions.
Make sure all classnames are accessible from their targetPackage, for example by making them public.
Diffblue Cover was unable to construct an instance of someClass
. Ensure there is a package-visible constructor or factory method that does not throw an exception for the class under test. If such a method is already present but Diffblue Cover does not find it, it can be specified using custom rules for inputs:
See for further troubleshooting of this issue.
The method under test could not be found in the execution trace. The trace file was only partially loaded because an error was found while loading it. Please record your application again with the Replay agent of your current installation of Diffblue Cover.
The method under test is not called in recorded execution trace. Record your program again and provide program inputs that trigger at least one call of the method under test.
Please ensure that temporary files are deleted in the method under test.
Diffblue Cover detected Spring on the classpath, but failed to load critical components while building the Spring context. Make sure these components can be loaded.
Try extending CrudRepository with concrete type parameters, or if the class should not be considered a repository then annotate the class with the @NoRepositoryBean
annotation.
Only skeleton tests have been created for this method, as requested by the user. These should be completed manually, as needed.
Some classes in the Spring context have @Value annotation that Diffblue Cover can't resolve. Usually variables for such annotations are provided in *.properties
files. Please check src/main/resources
and src/test/resources
. The default names for the files are application.properties
and application-test.properties
. If you use named Spring profiles please use application-<profile name>.properties
files.
Diffblue Cover does not support writing tests for methods that use virtual threads.
Controller tests cannot be written because CSRF protection is enabled by Spring-security. Write a custom configuration to deactivate CSRF for unit tests, which can then be imported in the base class for your test.
Diffblue Cover was unable to write a test using a value specified by an annotation.
Diffblue Cover skipped test creation for Spring repository. Check whether Spring boot tests are enabled. If they are not, enable them.
Mockito was unable to create a static mock for a class. Please review the underlying cause in the output message or log.
Diffblue Cover was unable to construct an instance of the class under test because a step in the arrange section threw an exception.
Diffblue Cover was unable to construct an instance. Diffblue Cover failed to create a parameter for the constructor or factory method call.
Diffblue Cover was unable to construct an instance. No suitable constructor or factory method found. Please check that the class under test has a non-private constructor or factory method.
Diffblue Cover was unable to test an instance of an enum as no constants are defined.
Diffblue Cover was unable to write a test that does not get into a potentially unbounded loop.
Diffblue Cover was unable to use the requested base class. Please check that the requested base class is public and has an accessible constructor.
Diffblue Cover was unable to create an instance of a required class.
Diffblue Cover does not support methods with names that coincide with reserved keywords
Diffblue Cover's default sandboxing policy disallowed test writing in order to prevent your code from damaging your system environment. Please see .
Diffblue Cover ran code in your project that tried to load a JNI library, violating the default security policy. See to resolve this issue.
Diffblue Cover tried to run the arrange/act section, but the method under test threw an error. Add constructors or factory methods that make it easier to construct fully initialized objects. Please see .
Diffblue Cover failed to create tests because it ran out of memory. See:
Failed to create Spring context. Check to see if there are any missing environment variables or system properties. For detailed and further troubleshooting please see .
Failed to create Spring context due to missing beans. Check to see if there are any missing environment variables or system properties. Also missing beans could be defined in Spring profiles that aren't used for test generation. For further detail troubleshooting Spring contexts please see . Otherwise, please contact with details of the entire output message and the source code of the class under test.
Diffblue Cover was only able to write tests that are time-sensitive. The assertions don't pass when run at an alternate date, time, and timezone. Try refactoring the method to take a java.time.Clock
instance so that the time can be parameterized during testing. See for details.