# 2023-03-02

This release introduces a lot of improvements to the tests that Diffblue Cover automatically writes. Due to the large amount of code updates Diffblue will make, we suggest rerunning Diffblue Cover to create a new baseline set of tests for all of your projects.

## Higher-quality test code for methods involving generic types

We have changed Cover to produce higher-quality test code when writing tests for methods involving generic types. In particular, we are more careful about preserving wildcards in type arguments.

In this release we have tweaked our test creation strategy in a few places which will result in many, intentional, changes to the test code written by Cover.

### Passing method type parameters instead of using casts when generating mocks

Previously, where Cover would have written:

```
  when(ownerRepository.findById((Integer) any())).thenReturn(owner);
```

...it will now write:

```
  when(ownerRepository.findById(Mockito.<Integer>any())).thenReturn(owner);
```

### Easier to read mocking

Cover no longer inserts casts before `Mockito.mock`; for instance, instead of:

```
  PostMetaServiceImpl postMetaService = new PostMetaServiceImpl(
      (BaseMetaRepository<PostMeta>) mock(BaseMetaRepository.class), mock(PostRepository.class));
```

...it will now write the simpler:

```
  PostMetaServiceImpl postMetaService = new PostMetaServiceImpl(mock(BaseMetaRepository.class),
      mock(PostRepository.class));
```

It's also worth noting that Cover now adds disambiguation casts more aggressively to distinguish between various overloads; in particular, you may see additional casts appear before `null` arguments.

## Better variable naming for tests

The names of variables that Cover creates now more closely reflect their usage; for instance, instead of:

```
  Pet pet = new Pet();
  LocalDate ofResult = LocalDate.of(1970, 1, 1);
  pet.setBirthDate(ofResult);
```

...the `ofResult` is replaced with `birthDate`:

```
  Pet pet = new Pet();
  LocalDate birthDate = LocalDate.of(1970, 1, 1);
  pet.setBirthDate(birthDate);
```

When Cover creates more than one variable of the same type, it now uses more intuitive numbering. For example, for three variables of the same type, instead of:

```
  PetType petType = new PetType();
  PetType petType1 = new PetType();
  PetType petType2 = new PetType();
```

...the numbering of the second variable of the same type is 2, the third is numbered 3:

```
  PetType petType = new PetType();
  PetType petType2 = new PetType();
  PetType petType3 = new PetType();
```

## IntelliJ IDEA 2023.1 support

Diffblue Cover now supports IntelliJ IDEA 2023.1 (Community and Ultimate). In keeping with our policy of supporting the current and previous release, Diffblue Cover now supports IntelliJ IDEA 2022.3 and 2023.1. Support for IntelliJ IDEA 2022.2 has been removed as of Diffblue Cover 2023.03.02.

## Enhancements

* IntelliJ Plugin: Cover now supports IntelliJ IDEA Community Edition 2023.1 and IntelliJ IDEA Ultimate 2023.1. \[Ref: TG-18633]
* Cover now produces more and better tests for code involving generics with wildcards. \[Ref: TG-17479]
* Cover now allows factories with class parameters to be specified in `DiffblueRules.yml`. See the ['Customizing test inputs' documentation](https://github.com/diffblue/website-docs/blob/develop/knowledge-base/cli/custom-inputs/README.md) for more details. \[Ref: TG-18761]
* Cover now selects better parameters for streams that are relevant for the method under test. \[Ref: TG-16964]
* Cover now has an improved ability to derive variable names from method parameter names in the code under test. \[Ref: TG-18804]
* Cover now has improved support for Spring 4.1.1. \[Ref: TG-18657]
* Cover now writes easier to read tests for Spring Repository `save(...)` methods so that they only `save` in the `Act` phase of tests. \[Ref: TG-18802]
* Reports: Cover now has simplified and clearer reporting dashboards. \[Ref: TG-18738]

## Resolved Issues

* Resolved an issue, which, in some circumstances, caused Cover to incorrectly report `R011` (Sandboxing policy violation) instead of `R020` (Temporary files were created but not deleted). \[Ref: TG-18778]
* Resolved an issue which caused `dcover coverage-reports` to report `E084: JaCoCo command failed` whilst using Surefire 3.0.0 when there are no existing manually written tests. \[Ref: TG-18762]
* Resolved an issue which, in some circumstances, would cause Cover to report `com.diffblue.cover.exception.limitation.SpringContextCreationException: Failed to create Spring context using package [...]`. \[Ref: TG-18743]
* Resolved an issue which, in some circumstances, caused Cover to report `R024` (Analysis service shutdown unexpectedly) and `R025` (Skipped due to previous failure). \[Ref: TG-18742]
* Resolved an issue which caused Cover to not exclude methods that throw `InterruptedException` from getters used in assertions. \[Ref: TG-18723]
* Resolved an issue which caused Cover to not consider using the current date as a test input, rather than just fixed dates. \[Ref: TG-18710]
* Resolved an issue which caused duplicate `Detected Mockito version` lines in the console and log files. \[Ref: TG-18692]
* CLI: Removed output code `E106` (Multiple versions of dependencies) which provided a non-actionable output. \[Ref: TG-18044]

## Known Issues

* Cover may produce tests for JUnit 4.10 and lower that do not compile due to the use of `assertNotEquals`. \[Ref: TG-17605]
* IntelliJ Plugin: Upgrading to IntelliJ IDEA 2022.3 may, in some circumstances, cause existing run configurations to no longer produce tests. Removing any run configurations for that entity and writing tests again will recreate a working run configuration. \[Ref: TG-18282]


---

# 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/2023-03-02.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.
