0

Im trying to run some selected tests from my Test class based on the test case name.

Below is an outline of my test class

----GlobalTests.java----

@Test
public void myTest_India(){ --- }

@Test
public void myTest_Germany() { --- }

----GlobalIntegrationTests.java----

@Test
public void myIntegrationTest_India(){ --- }

@Test
public void myIntegrationTest_Germany() { --- }

How do I instruct my maven to run only 'India' tests?

I've tried in maven surefire plugin as below

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M5</version>
                <configuration>
                    <includes>
                        <include>%regex[*Test_India*]</include>
                    </includes>                    
                </configuration>
            </plugin>

But seems like this configuration is for selecting test class names and NOT test names.

Thanks in advance.

SP.
  • 85
  • 3
  • 13
  • https://stackoverflow.com/questions/33250009/is-there-a-way-using-surefire-to-exclude-tests-at-a-test-method-level-not-a-cl – M A Aug 13 '20 at 14:38
  • 1
    @MAnouti Thank you for the pointer. – SP. Aug 13 '20 at 16:11

1 Answers1

0

This can be done by using maven's 'test' property Tests to be run can be defined as testClass#testName Below approach worked

<project>
    <properties>
        <test>*#*India</test>
    </properties>
</project>

and run as

mvn test

or directly from the command line as mvn -Dtest="*#*India"

SP.
  • 85
  • 3
  • 13