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:

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

    // Act

Disabling the creation of boilerplate tests

In order to switch off this feature, uncheck the box for Generate boilerplate tests under Fallback Options on 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 ""