Specify which Junit test to run

I am using Selenium Junit Maven and Jenkins, what's the best way to specify which tests to run? I tried Categories but found it too complicated. Is there an easy way to tell which methods / class to run?

+3


source to share


1 answer


While I believe Categories are the way to go, you can alternatively include / exclude test classes in the surefire plugin config.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.18.1</version>
    <configuration>
      <includes>
        <include>Sample.java</include>
      </includes>
    </configuration>
  </plugin>

      

If you want to do one test method you can specify the propertytest



mvn -Dtest=TestCircle#mytest test

      

You can also set a property test

in your pom.xml and set it differently in different profiles, but in the end, categories are better than that and good test suite design practice.

+3


source







All Articles