Search code examples
maven-3maven-pluginjunit5maven-surefire-plugin

maven-surefire plugin is not running few of the Junit5 test profiles


We've a simple Junit/Junit5 & Maven-surefire based test framework.

We run the tests using following commands:

mvn clean test -PlistingGROUP
mvn clean test -PsignUpGROUP
mvn clean test -PloginGROUP

The groups are defined under section of the POM.xml

  <profile>
        <id>listingGROUP</id>
        <properties>
            <groups>listingTag</groups>
        </properties>
    </profile>

    <profile>
        <id>loginGROUP</id>
        <properties>
            <groups>loginTag</groups>
        </properties>
    </profile>

    <profile>
        <id>signUpGROUP</id>
        <properties>
            <groups>signUpTag</groups>
        </properties>
    </profile>
        <profile>
        <id>allTests</id>
        <properties>
            <groups>signUpTag,listingTag,loginTag</groups>
        </properties>
    </profile>

The surefire plugin is defined under build section of the POM.xml

           <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.22.0</version>
            <!--                   ***********************************************************************     -->
            <!--                                ***OPTION 2:: Configure groups , as below & remember to disable Option1 ***-->
            <!--                   ***********************************************************************     -->
            <!--                                <configuration>-->
            <!--                                        <groups>smokeTag</groups>-->
            <!--                                </configuration>-->
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>8</source>
                <target>8</target>
            </configuration>
        </plugin>

When test are run using maven command, its skipping listing tests (when ran indivisually or as part of allTests profile) I tried to create new test class & noticed that- its only running Signup tests & login tests

enter image description here

enter image description here

enter image description here

enter image description here

POM.xml details:


Solution

  • Issue got resolved after removing, all of Juni4 dependencies from the project & after correcting imports to modern Junit5 Jupiter imports,

    import org.junit.jupiter.api.*;
    

    instead of having import conflicts

    import org.junit.Before;
    import org.junit.Test;
    import org.junit.jupiter.api.*;