2025-08-02

This release introduces enhanced support for custom Spring annotations and improves performance in Spring projects. Test quality is also strengthened with stronger assertions, improved readability, and better handling of builder patterns.


Spring Framework Support

  • Custom Annotation Detection: Diffblue Cover now detects and handles custom Spring annotations that are defined using Spring meta-annotations. A new environment variable, DIFFBLUE_AUTOWIRED_ALTERNATIVE, allows you to replace the @Autowired annotation with a specified custom alternative in your generated tests.

  • Improved Performance: To prevent performance issues during test creation, Cover now mocks Spring's ApplicationContext when it falls back to creating non-Spring tests within a Spring project.


Improved Test Quality & Strength

  • Stronger SQL Tests: Cover now writes stronger tests for code that uses java.sql.ResultSet by creating assertions on column values. It also prioritizes user-defined factories annotated with @InterestingTestFactory to increase test coverage.

  • Builder Pattern Support: An issue has been resolved that prevented Cover from writing tests for classes using the builder pattern. Tests for these classes are now generated successfully, including assertions on the state set by setters.

  • Enhanced Test Readability: To produce cleaner and more maintainable tests, Cover now avoids unnecessarily mocking objects, such as entities, when it can create an instance directly.


Configuration & Integration

  • New Test Filters: To resolve an issue that could cause the Maven Spotless plugin to fail, DiffblueBuild.yaml v2.2 introduces new test filters for file and class matching (DIFFBLUE_TEST_*_PATTERN), which support both glob and regex formats. Existing REGEX filters remain supported for backward compatibility. For more details, see our documentation.


Important Notices

Upcoming Improvement to Test Readability

In an upcoming release, Cover will improve which methods are inlined, in particular in fluent-style method call chains such as builders. While this produces higher quality tests, please be aware that existing tests for affected classes will change, leading to noticeable changes in your test suite upon update.

Deprecation of Inlining Options

The inlining options (CLI: --act-into-assert, --arrange-into-act-assert, --inline-constants , --inline-constructors; Plugin: 'Test Style' dropdown and checkboxes 2-6 in the ‘Test Formatting’ panel) are now deprecated and will not have any effect on the code output. They will be removed in an upcoming Cover release. Please ensure these options are not used in any automated scripts.

Upcoming Breaking Change in DiffblueBuild.yaml

This only applies to projects that have a DiffblueBuild.yaml file. To speed up Diffblue Cover CLI, a new phase will be introduced in DiffblueBuild.yaml in an upcoming release. Instructions will be provided on how to update your DiffblueBuild.yaml file before updating the CLI (e.g. in CI/CD).

Enhancements

  • Diffblue Cover now writes stronger tests for code using java.sql.ResultSet by creating assertions on column values. It also prioritizes user-defined factories annotated with @InterestingTestFactory, increasing test coverage and custom mocking capabilities. [Ref: TG-23665]

  • Diffblue Cover now mocks Spring's ApplicationContext when it falls back to creating non-Spring tests in a Spring environment. This change avoids instantiating a full ApplicationContext, which could previously cause performance issues during test creation. [Ref: TG-23628]

  • Diffblue Cover now detects and handles Spring-derived custom annotations, i.e. the annotation is in turn annotated with its corresponding Spring annotation. A new environment variable, DIFFBLUE_AUTOWIRED_ALTERNATIVE, allows for selecting the custom annotation to be used in the test output. If not specified, Diffblue Cover continues to use @Autowired in the generated tests. [Ref: TG-23328]

Resolved Issues

  • Resolved an issue where Diffblue Cover would encounter an internal error and fail to write tests for methods with certain complex conditions. Test generation for this code is now unblocked. [Ref: TG-23667]

  • Resolved an issue that prevented Diffblue Cover from writing tests for classes using the builder pattern, particularly when assertions were needed on the state set by setters. Tests for these builder classes are now generated successfully. [Ref: TG-23565]

  • Resolved a Windows-specific issue where Diffblue Cover was unable to generate tests for some methods, resulting in an F009 internal error. This prevents failures that produced the message "An operation was attempted on something that is not a socket". [Ref: TG-23550]

  • Resolved an issue that could cause the Maven Spotless plugin to fail. DiffblueBuild.yaml v2.2 introduces new test filters for file and class matching (DIFFBLUE_TEST_*_PATTERN), supporting both glob and regex formats. Existing REGEX filters are still supported for backward compatibility. [Ref: TG-23390] Docs

  • Resolved an issue where Diffblue Cover would generate tests with unnecessary mocks for instantiable objects. Tests for code using patterns like entity objects are now more readable and contain fewer mock setups. [Ref: TG-21664]

Known Issues

  • Plugin: Diffblue Cover incorrectly displays a menu option to write tests for existing test files. [Ref: TG-17163]

  • Cover supports Open JDK and Oracle JDK; results with other JDKs may differ due to the variability in their implementations of Java. [Ref: TG-19345]

  • Cover may encounter an F009 (Internal error) caused by a ClassCircularityError involving org/mockito/configuration/MockitoConfiguration when writing tests with Mockito 5. To avoid this, use an earlier version of Mockito. Downgrading to Mockito 4.x is the recommended workaround. [Ref: TG-19610]

  • Reports: Cover only counts Java code towards the total line count metrics. Kotlin code is not currently included. [Ref: TG-22088]

  • Reports: Total lines of code metric can incorrectly count a multi-line comment at the end of a line of code, resulting in fewer than expected lines counted. [Ref: TG-22089]

  • Reports: Following an upgrade, the 'Total Lines of Code' card may show 0 until a new reports bundle has been uploaded. [Ref: TG-22094]

  • In some circumstances, Cover may write more simplistic tests with less meaningful assertions when Spring Boot dependency injection is disabled. [Ref: TG-22102]

  • In some circumstances, Cover will still write Spring Boot tests when Spring Boot dependency injection is disabled. [Ref: TG-22103]

  • Cover may write failing TestNG tests when Spring Boot dependency injection is disabled. [Ref: TG-22107]

  • Plugin: On some displays, the Test Review subsection title "Tests for review" can be malformed. [Ref: TG-22805]

  • Diffblue Cover does not currently support test creation for projects using Java 24; please use JDK 21 or lower. [Ref: TG-22920]

Last updated

Was this helpful?