How to run all tests in a particular package with Maven?

后端 未结 9 1638
别跟我提以往
别跟我提以往 2021-01-30 02:18

I can find in the Maven docs where it shows how to run:

  1. A single test
  2. All tests in a single test class
  3. All tests in classes matching a particular
9条回答
  •  南方客
    南方客 (楼主)
    2021-01-30 02:35

    AFAIK there are no command line parameter for surefire:test to run tests in a specific package.

    I use a configuration variable to achieve the same effect. A fragment of my pom.xml:

    
        
            
                org.apache.maven.plugins
                maven-surefire-plugin
                2.7.2
                
                    
                        **/${testGroup}/*Test.java
                    
                
            
        
    
    

    Now if I want to run tests in a package named "com.example", I use the following command:

    mvn test -DtestGroup=com/example
    

提交回复
热议问题