前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >JUnit 注解@SuiteClasses的工作原理

JUnit 注解@SuiteClasses的工作原理

作者头像
Jerry Wang
发布2020-08-17 19:54:27
5990
发布2020-08-17 19:54:27
举报

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:

代码语言:javascript
复制
<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:

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2020-08-16 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档