Skip to main content

Tutorial: Using Symflower with JUnit 4 and JUnit 5

Out of the box, Symflower supports both JUnit 4 and JUnit 5. For projects using Maven and Gradle, Symflower will automatically detect the right framework to use. You can also manually configure Symflower to use either JUnit 4 or JUnit 5:

Select the testing framework you want Symflower to use.

Here's an example of the two different test templates Symflower will generate for JUnit 4 vs JUnit 5. The following example code relies on the class Triangle which resides in another package:

package com.symflower.example;

import com.symflower.shapes.Triangle;
import com.symflower.shapes.TriangleType;


public class Utils {
Triangle initTriangle() {...}
...
}

The generated test template file looks as follows. Note that the necessary import for Triangle and the required dependencies for unit testing with JUnit 5 have been added automatically:

package com.symflower.example;

import com.symflower.shapes.Triangle;
import com.symflower.shapes.TriangleType;
import org.junit.jupiter.api.*;
import static org.junit.jupiter.api.Assertions.*;

public class UtilsTest {
...
}