maven项目的目录结构:
执行 PgCsControllerTest.java这个类(命令执行需要在pom.xml文件所在的目录下)
$ mvn -Dtest= com.pg.controller.PgCsControllerTest test
或者
$ mvn test -Dtest= com.pg.controller.PgCsControllerTest
说明解释:
使用 mvn test执行单元测试的时候,默认情况是把工程所有的 test case 都执行一遍。如果需要执行某一个 PgCsControllerTest.java类,可以通过上面的命令。其中-Dtest参数就是关键,参数的值为“com.pg.controller.PgCsControllerTest” 这个是要执行的单元测试类名,需要包含package即可。
我们也可以试用eclipse,配置快捷方式: