JUnit 注解@SuiteClasses的工作原理 JUNITSAPSAP云平台SAP Cloud PlatformSAP成都研究院
Suppose I have four test cases in my project, the total methods to be tested:
Based on the blog Run only given sets of your unit test via @Category, it is possible to organize test methods within THE SAME CLASS to different categories via @Category, that is, the granularity to control which test methods should be executed is method level.
There is another annotation @SuiteClasses which can allows us to categorize test classes into different test suites, and once we specify a given test suite to be executed, all test classes within that suite would be executed one by one.
For example, I create a suite TestSuite1and2 and only put first and second test case into it, so when this test suite is executed, only three test methods ( 1 from first test case and 2 from second test case ) are executed:
And the same logic for TestSuite2and3:
If you need to integrate test suite execution into Maven, add the following parts in pom.xml:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<includes>
<include>${runSuite}</include>
</includes>
</configuration>
</plugin>
Then use the following command line:
You will get exactly the same result as in Eclipse:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
推荐阅读
-
JUnit 注解@RunWith的工作原理 JUNITJavaSAPSAP云平台SAP Cloud Platform
-
SAP S/4HANA CDS view的扩展原理 CDS viewCloudSAP成都研究院SAP Cloud PlatformSAP云平台
-
SAP CRM Location Assignment的实现原理 SAPSAP云平台SAP Cloud PlatformSAP成都研究院Cloud
-
SAP CRM Application Extension Tool类型为Code List的扩展字段实现原理 SAPSAP云平台SAP Cloud PlatformSAP成都研究院Cloud
-
SAP Fiori globalization实现原理之Number显示的格式原理 sapSAP云平台SAP Cloud PlatformSAP成都研究院Cloud
-
使用Chrome开发者工具分析JavaScript garbage collector(垃圾回收器)的实现原理 chromeSAPSAP云平台SAP Cloud PlatformSAP成都研究院
-
JUnit 注解@RunWith的工作原理 JUNITJavaSAPSAP云平台SAP Cloud Platform
-
JUnit 注解@SuiteClasses的工作原理 JUNITSAPSAP云平台SAP Cloud PlatformSAP成都研究院
-
JUnit 注解@Rule的工作原理 junitSAPSAP云平台JavaSAP Cloud Platform
-
JUnit 注解@Category的工作原理 junitjavaSAPSAP云平台SAP Cloud Platform