JUnit 註解@SuiteClasses的工作原理
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的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2722717/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- JUnit 註解@RunWith的工作原理
- JUnit 註解@Category的工作原理Go
- JUnit 註解@Rule的工作原理
- Java JUnit框架裡@Category註解的工作原理Java框架Go
- 使用Java JUnit框架裡的@SuiteClasses註解管理測試用例Java框架UI
- Angular @Injectable 註解的工作原理淺析Angular
- Spring框架裡註解@Autowired的工作原理Spring框架
- JUnit5註解學習指引
- SAP Fiori @OData.publish 註解的工作原理解析
- 暑期自學 Day 07 | Junit,反射,註解(一)反射
- 暑期自學 Day 08 | Junit,反射,註解(二)反射
- 使用Java JUnit框架裡的@Rule註解的用法舉例Java框架
- Spring系列之新註解配置+Spring整合junit+註解注入Spring
- Transaction註解原理
- Angular @Inject 註解的實際應用例子和工作原理淺析Angular
- SAP Fiori 註解 @ObjectModel.readOnly工作原理解析Object
- @LoadBalanced註解原理
- JAVA 註解的基本原理Java
- Java註解與原理分析Java
- 深入瞭解Azure 機器學習的工作原理機器學習
- Nginx的工作原理和配置詳解Nginx
- spring JUnit 基本原理Spring
- SpringMVC工作原理詳解SpringMVC
- JUnit5學習之五:標籤(Tag)和自定義註解
- 代理伺服器的工作原理詳解伺服器
- SAP Fiori程式設計模型規範裡註解 - @OData.publish工作原理解析程式設計模型
- Struts2工作原理(圖解)圖解
- 交換機的作用、功能和工作原理詳解
- 解讀MySQL的InnoDB引擎日誌工作原理MySql
- Mirror 的工作原理
- Spark的工作原理Spark
- View的工作原理View
- HashMap的工作原理HashMap
- DHCP的工作原理
- tcmalloc的工作原理
- undo的工作原理
- OAuth的工作原理OAuth
- 從 java 註解分析 ButterKnife 工作流程Java