How to automatically run tests?

Viewed 163

Which properties will be added to run tests automaticlly in JUNIT5? How do I configure this?

2 Answers

You should use the maven-surefire-plugin, for example:

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <argLine>-Xmx1024M ${additional.test.jvm.args}</argLine>
                <excludes>
                    <exclude>**/*ManagedTest.java</exclude>
                </excludes>
                <runOrder>alphabetical</runOrder>
            </configuration>
        </plugin>
    </plugins>
</build>

Then if you run mvn test your code will be both compiled and the tests will be run.

you can use maven plugin for it:

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>${maven-surefire-plugin.version}</version>
                    <configuration>
                        <includes>
                            <include>**/*Test.java</include>
                        </includes>
                        <excludes>
                            <exclude>**/integration/*ITTest.java</exclude>
                        </excludes>
                    </configuration>
                </plugin>

for more information see doc

Related