Knowledge Base > IntelliJ Plugin > Creating boilerplate tests

Creating boilerplate tests

Boilerplate mode

Normally, selecting  or 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 can use the "boilerplate" mode, if enabled (see below), 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

Enabling the creation of boilerplate tests

In order to switch this feature on, under File -> Settings (Windows/Linux) or IntelliJ IDEA -> Preferences (macOS), select Tools -> Diffblue Cover, then select the Generation tab of the Diffblue Cover configuration screen, and in the Fallback Options section, check the box for Generate boilerplate tests.