Suppose I have four test cases in my project, the total methods to be tested: 7
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+in+java+真正的测试用例实战
JUnit是Java编程语言的单元测试框架,用于编写和可重复运行的自动化测试。JUnit4通过注解的方式来识别测试方法。目前支持的主要注解有(下列注解标示了单元测试的不同运行阶段执行的代码): @BeforeClass 全局只会...
java测试用例JUnit教程
Java开发测试用例实战,使用JUnit
使用eclipse快速开发test Case: 如下图:右键选择你要测试的类,在新建中点击“JUnit 测试用例”,
(1)首先对于开发人员来说大大减少调试工作的时间,同时也规范了对于代码安全管理(我们知道那些方法是可以调用的); (2) 对于整个项目来说,有了完整的测试,保证项目最后交付测试有了可靠依据; (3)对于...
junit测试用例calculate一个简单的用例帮助掌握junit方法
推荐_JUnit in java 真正的测试用例实战
在JUnit中使用@Rule测试文件和目录Java开发Java经验技巧共3页.pdf.zip
这是一个软件测试的论文作业,主要写的是junit的安装过程和使用过程,里面由一个测试用例以及其用例结果,是我们的课程作业。希望对大家由帮助。
通过ant对各种语言脚本做运行管理,并输出报告!
JUnit是一个开放源代码的Java测试框架
使用用例场景设计测试用例 测试 软件工程 JUnit
@Priority注解测试用例的优先级,有High.class, Middle.class, Low.class可选 @Comment注解测试用例的注释 以上三种注解和Junit build-in的注解@Test配合使用,示例如下 import org.junit.Test; import org.sdet....
软件测试基本路径法设计测试用例Junit单元测试归纳.pdf
软件测试JUnit测试框架的使用实验1报告
springboot整合junit测试用例demo
junit让学会使用它,加油啊,有好东西大家分享吗???????????//
Junit4测试用例示例
原文地址:https://dev-cheats.com/java/unit-testing-best-practices-junit-reference-guide.html 这个资源是把文章整理成PDF,方便本地查看。