Tests generated by Diffblue Cover

Boilerplate tests

Normally, selecting Write Tests will generate one test per method. If the Diffblue Cover IntelliJ plugin is unable to create a usable test for a method, it will switch, by default, into "boilerplate" mode, where it will produce a template for a test based on values relevant to the source code under test. This will save test developers time over writing tests from scratch.

For example, the method in the following inner class in an outer class, DatabaseDao:

public static class Inner {
    private Inner(){};
    public void myMethod(Inner inner) {
    }
}

could produce a boilerplate test like this:

  @Test
  public void testInnerMyMethod() throws Exception {
    // Arrange
    String string = "This is a boilerplate test. Please fix.";
    Assert.fail(string);
    DatabaseDao.Inner inner = null;
    DatabaseDao.Inner inner1 = null;

    // Act
    inner.myMethod(inner1);
  }

Disabling the creation of boilerplate tests

In order to switch off this feature, uncheck the box for Generate fallback boilerplate tests at the bottom of the Generation tab of the Diffblue Cover configuration screen which can be found at Tools -> Diffblue Cover -> Generation -> Test Naming, under File -> Settings (Windows/Linux) or IntelliJ IDEA -> Preferences (macOS):

results matching ""

    No results matching ""