Skip to main content

Test template generation

Generate test template

Symflower's test templates provide you with all the boilerplate code that you would otherwise type manually. The plugin generates the necessary imports, annotations, object initializations, function calls, asserts, and more at once, leaving you in charge of defining the actual values for testing.

Example: Generating test templates with Symflower

When using Symflower for the following method:

public class Triangle {
...

public boolean isValid() {
// Each side needs to be greater than 0
if (this.sideA <= 0 || this.sideB <= 0 || this.sideC <= 0) {
return false;
}

// Two sides need to be bigger than the third
if (this.sideA + this.sideB < sideC ||
this.sideB + this.sideC < this.sideA ||
this.sideA + this.sideC < this.sideB) {
return false;
}

return true;
}
}

The test template generated by Symflower looks like this:

    @Test
public void isValid() {
Triangle t = new Triangle(123, 123, 123);
boolean expected = true;
boolean actual = t.isValid();

assertEquals(expected, actual);
}
    @Test
public void isValid() {
Triangle t = new Triangle(123, 123, 123);
boolean expected = true;
boolean actual = t.isValid();

assertEquals(expected, actual);
}
Application Frameworks

Symflower supports Spring Boot offering more boilerplate code specific to Spring Boot tests

Using Symflower's test template generation: