kajaa71
kajaa71

Reputation: 21

How to automatically run tests?

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

Upvotes: 2

Views: 724

Answers (2)

Dmitrii B
Dmitrii B

Reputation: 2860

You can use a 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 documentation.

Upvotes: 2

stephan f
stephan f

Reputation: 622

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.

Upvotes: 3

Related Questions