Search code examples
javamavenjenkinsjunitcategories

How to split JUnit Tests in a Jenkins


I am trying to split my tests using Junit categories for Jenkins. I read all the guides online and did the following.

  1. Created an interface
public interface regression {}

  1. Added annotation to test
    @Category(regression.class)
    @Test
    public void myTest(){} 
  1. Added the group to POM.XML
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.21.0</version>
                <configuration>
                    <properties>
                        <property>
                            <name>listener</name>
                            <value>test_listener.TestListener</value>
                        </property>
                    </properties>
                    <groups>categories.regression</groups>
                </configuration>
            </plugin>

I wrote the following terminal:

mvn clean test -Dtest=categories.regression

and received this error message:

 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.21.0:test (default-test) on project automation: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]

Solution

  • I would try running the command again, but using -Dgroups=categories.regression instead of -Dtest

    Also, check out: