What's New > Version 2021.01.01

Enhancing the readability of tests

Release date: Jan 11, 2021

Enhancements to readability of long arrange sections

It can often be challenging to follow the creation of large and complex objects in the arrange section of tests. The arrange section has been enhanced to make the setup more representative of a human written test.

@Test
  public void testShowOwner2() throws Exception {
    // Arrange
    Owner owner = new Owner();
    owner.setLastName("Doe");
    owner.setPetsInternal(new HashSet<Pet>());
    owner.setFirstName("Jane");

    PetType petType = new PetType();
    petType.setName("Dog");

    Pet pet = new Pet();
    pet.setOwner(owner);
    pet.setVisitsInternal(new ArrayList<Visit>());
    pet.setName("Bella");
    pet.setType(petType);

    HashSet<Pet> petSet = new HashSet<Pet>();
    petSet.add(pet);

    Owner owner1 = new Owner();
    owner1.setLastName("Doe");
    owner1.setPetsInternal(petSet);
    owner1.setFirstName("Jane")
    ...
  }

Feedback

If you have feedback, questions or requests regarding the Diffblue Cover IntelliJ Plugin, please contact us on the community forum. We would love to hear about what is important to you and what you would like to see in upcoming releases.

How do I automatically maintain all of these tests?

Use Diffblue Cover on any CI platform to automatically update your unit tests and catch regressions for every commit - watch this video to learn more


Full Release Notes

Enhancements

  • CLI: Cover now logs an error if a project has Spring dependencies with mismatching versions. [Ref: TG-13401]

  • CLI: Cover now logs an ERROR when the spring-boot-test dependency is missing from the classpath whilst working with a Spring project. [Ref: TG-13400]

  • CLI: Cover’s test creation summary table has been made more readable. Additionally, other small improvements have been made to increase log file readability. [Ref: TG-13263]

  • Cover now uses blank lines to divide the arrange section of tests to improve readability. [Ref: TG-13123]

Resolved Issues

  • Resolved an issue where further guidance for working with R013 reason codes linked to an unavailable webpage. [Ref: TG-13435]

  • Resolved an issue where java.lang.AssertionError : Can’t read field logger may be logged to the console/event log when attempting to write tests for some projects. Additionally, other causes of ‘Unrecoverable errors’ (E009) have been fixed. [Ref: TG-13385]

  • IntelliJ Plugin: Resolved an issue where, in some circumstances, if a project was closed and then reopened in the same instance of IntelliJ, the Diffblue index for this project could become significantly larger than expected. [Ref: TG-13336]

Known Issues

  • CLI: Windows: creating config.json by outputting --example-config as file causes exceptions. [Ref: TG-11198]

  • CLI: All tests may be discarded in test validation when using --config. [Ref: TG-11475]

  • CLI: dcover clean --working-directory throws an error if --test-output-dir is not provided. [Ref: TG-11665]

  • CLI: dcover fails to generate tests, reporting java.lang.OutOfMemoryError, when analysing projects which spawn a quantity of threads in excess of the operating system’s process thread limit. [Ref: TG-11680]

  • CLI: dcover clean --failing fails when used with a Gradle project. [Ref: TG-11707]

  • CLI: Test validation may fail on a Gradle project due to an incompatibility between Gradle and Cover. If you encounter this issue, run with --skip-test-validation. [Ref: TG-12045]