Refer to http://www.blogjava.net/sitinspring/archive/2007/06/20/125224.html and run the JUnit classes with Maven. But the run MVN test, but reported that no test class found, namely: There are no tests to run.
When you're depressed, check out the MAVEN reference and find out that it was the default behavior of the Surefire plug-in. MAVEN performs tests using the Surefire plug-in, which finds the matching test class by the class name in the specified format, and the default containing test class:
**/*test.java
**/test*.java
**/*testcase.java
Default excluded Test classes:
**/abstract*test.java **/abstract*testcase.java
So by default, such as "Add_exist_department.java" or "Add_exist_departmenttests.java" This JUnit class is not discovered and executed by MAVEN and can be modified as follows to include the "**/*tests.java" test class for the purpose of Surefire: <build> <plugins > <plugin> <groupid>org.apache.maven.plugins</ groupid> <artifactId>maven-surefire-plugin</artifactId> <configuration> <includes> & nbsp;<include>**/*tests.java</include> </includes> & nbsp <excludes> <exclude>**/abstract*.java</exclude > </excludes> </configuration> & nbsp;</plugin> </plugins> </build>
Run the specified test class: >MVN Test-dtest=[classname]
Run the method specified in the test class: (this requires maven-surefire-plugin:2.7.3 above version to support) >MVN Test-dtest=[classname]#[methodname] [methodname] to be shipped The method name of the row, support * wildcard character, example: 1 >mvn test-dtest=myclasstest#test1 2) >mvn test-dtest=myclasstest#*test*
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.