# 2025-06-01

## 2025-06-01

This release improves test generation, particularly for `java.util.Optional` and mock configurations. It also brings new CLI options for preflight checks and targeted JaCoCo coverage, alongside several key fixes and a new configuration warning.

* **Test Generation & Quality**:
  * New attributes for `@InTestsMock` allow specifying return values in mocked methods, yielding more domain-specific mock behaviors.
  * Improved test generation for `java.util.Optional` by better considering `isPresent` status, leading to more robust tests and coverage.
  * Fix for Mockito `any()` calls with bounded generic parameters now correctly uses wildcards, improving test compilation and coverage.
* **CLI Enhancements & User Control**:
  * New `--new-jacoco-coverage` option for `dcover create` solely writes tests that contribute new JaCoCo coverage, helping manage test volume.
  * Fix for environment summary not accurately reporting test validation status when disabled by an `E022` error.
* **Configuration & Plugin Usability**:
  * New warning for configured test output directories not matching `src/test/java`, helping identify misconfigurations early.
  * Plugin fix: Unchecking "Override test directory" now correctly clears prior settings, and re-checking defaults to `src/main/java`.

## Important Notices

### Changes to test code

* **Test formatting**: In a future release, Cover will switch the default test formatting style to `google-java-format`. This will cause a one-time churn, resulting in larger-than-usual diffs in your test code. If you prefer a different style, an alternative formatter configured in your build system will override this new default.

### Deprecated Features

* **`--existing-coverage` option**: The CLI option `--existing-coverage` for the `dcover create` command is deprecated as of release 2025.06.01 and is scheduled for removal in release 2025.06.02. This option was originally designed to use a JaCoCo file to guide test creation towards uncovered lines. To provide a more effective and streamlined experience for this functionality, it is being replaced. Users aiming to write tests focused on new coverage should now use the new `--new-jacoco-coverage` option, introduced in release 2025.06.01, which offers an enhanced and more direct approach.

### Enhancements

* CLI: Diffblue Cover now displays a concise summary of environment checks if `dcover remove` is invoked with the `--preflight` option. This offers users a quick overview of prerequisites for the remove command. \[Ref: TG-23186]
* CLI: Diffblue Cover now features the `--new-jacoco-coverage` option for the `create` command, allowing it to solely write tests that contribute new JaCoCo coverage. This helps manage the volume of tests by adding only those that expand coverage. \[Ref: TG-23149]
* Diffblue Cover now issues a warning message if the configured test output directory is not `src/test/java`. This helps users identify potential misconfigurations before tests are created. \[Ref: TG-23101]
* Diffblue Cover now provides new attributes for the `@InTestsMock` annotation, enabling users to specify return values for methods in mocked classes. This allows Diffblue Cover to generate tests with more domain-specific mock behaviors. \[Ref: TG-23049]
* Diffblue Cover now writes tests with improved consideration for the `isPresent` status of `java.util.Optional` objects. This leads to better test generation and coverage for code involving `Optional`s. \[Ref: TG-22868]

### Resolved Issues

* Plugin: Resolved an issue where Diffblue Cover would use a previous override test directory value even if the "Override test directory" checkbox was unchecked. Unchecking now clears the prior setting, and re-checking defaults to "src/main/java". \[Ref: TG-23191]
* Resolved an issue where Diffblue Cover sometimes wrote Mockito `any()` calls using an explicit object type instead of a wildcard for bounded generic parameters. This allows more generated unit tests to compile successfully, improving test coverage. \[Ref: TG-23185]
* CLI: Resolved an issue where Diffblue Cover's environment summary did not properly reflect that test validation was disabled by an `E022` error (JUnit Jupiter Launcher not found). This status is now accurately reported. \[Ref: TG-21636]

### Known Issues

* Plugin: Cover incorrectly provides a menu option to write tests for a test file. \[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]
* 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]
* Cover does not currently support Java 24. Please switch your JDK version to 21 or lower. \[Ref: TG-22920]


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cover-docs-preview.diffblue.com/updates-and-upgrades/release-archive/2025-06-01.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
