What's New > Version 2021.05.01

Icon now available as a shortcut to writing tests in the IntelliJ plugin

Release date: May 10, 2021

The Code Coverage Paradox Webinar - sign up now!

Code coverage is a metric everyone knows, but does high coverage equate to failure free systems? Not necessarily. In this webinar, we will discuss the key code metrics you should measure to lower risk and share best practices for both manual and automated processes that will help your development teams succeed.

Sign up here to join us on 19th May!

 

IntelliJ Plugin Enhancements 

  • There are now icons next to classes and public methods. Simply click  to write tests! 
  • You can now configure where the Diffblue Cover indexes are stored. Within the indexing configuration option, browse to the directory you want to store the indexes in.

General enhancements:

  • Cover now supports older Mockito versions, from 1.9.5 up to 3.9.0.
  • Tests for trivial constructors, setters and getters are now combined into one test resulting in more efficient use of code whilst retaining the same test coverage.
  • Cover now writes tests for:
    • More Spring Controller methods,  
    • Methods with Optional return value. For example:

Example input:

class DiffblueConsultantChatRobot {
  public Optional<String> getNextRobotAnswer(String userSays) {
    if (userSays.equals("I already use Cover, I love it!")) {
      return Optional.of("Great, can I interest you in more licenses?");
    } else if (userSays.equals("My developers won't write unit tests")) {
      return Optional.of("Cover can help and you'll love it!");
    } else {
      return Optional.empty();
    }
  }
}

Example output:

public class ChatBotDiffblueTest {
  @Test
  public void testNextAnswer() {
    // Arrange, Act and Assert
    assertFalse((new ChatBot()).nextAnswer("Question").isPresent());
  }
  @Test
  public void testNextAnswer2() {
    // Arrange and Act
    Optional<String> actualNextAnswerResult =
      (new ChatBot()).nextAnswer("I already use Cover, I love it!");
    // Assert
    assertTrue(actualNextAnswerResult.isPresent());
    assertEquals("Great, can I interest you in more licenses?", actualNextAnswerResult.get());
  }
  @Test
  public void testNextAnswer3() {
    // Arrange and Act
    Optional<String> actualNextAnswerResult =
      (new ChatBot()).nextAnswer("My developers won't write unit tests");
    // Assert
    assertTrue(actualNextAnswerResult.isPresent());
    assertEquals("Cover can help and you'll love it!", actualNextAnswerResult.get());
  }
}

Diffblue Cover Community Edition is available for use with commercial code

Community Edition allows you to write tests for both open source and commercial code. This means you can now use Diffblue Cover Community Edition at work completely for free. Visit our documentation to learn more about how you can use Diffblue Cover at work, and also see our End-User License Agreement

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

  • IntelliJ Plugin: Cover now allows users to configure where internal indexes are stored. [Ref: TG-14260]

  • IntelliJ Plugin: Cover now places icons adjacent to classes and public methods. These can be clicked to write tests for those classes and methods. [Ref: TG-14151]

  • CLI: Cover now supports specifying system properties via -D or --define arguments. [Ref: TG-14354]

  • CLI: Cover now uses an external process whilst writing tests, improving robustness around resource exhaustion scenarios, such as OutOfMemory or running out of threads. [Ref: TG-13873]

  • Cover now writes tests for more Spring Controller methods with PathVariable arguments, supporting a wider set of types of such arguments. [Ref: TG-14337]

  • Cover now supports older Mockito versions, from 1.9.5 up to 3.9.0. [Ref: TG-14167]

  • Cover now creates tests for constructors, setters and getters in combined tests instead of testing them separately. This results in fewer tests being written, but with the same test coverage. [Ref: TG-11208]

  • Cover is now able to write assertions for return values of type Optional. [Ref: TG-14297]

Resolved Issues

  • Resolved an issue where reported error codes for Spring class test creation may not be accurate. [Ref: TG-14320]

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 clean --failing fails when used with a Gradle project. [Ref: TG-11707]

  • IntelliJ Plugin: Diffblue Cover was unable to create an index error may appear if switching project happens before Cover has finished indexing. [Ref: TG-13772]