`
JerryWang_SAP
  • 浏览: 972449 次
  • 性别: Icon_minigender_1
  • 来自: 成都
文章分类
社区版块
存档分类
最新评论

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的原创文章,请关注公众号"汪子熙":

0
2
分享到:
评论

相关推荐

    MyBatis 需要注意的地方junit注解

    1.junit 常用注解 @Before 初始化方法,每次测试方法调用前都执行一次。 @After 释放资源:每次测试方法调用后都执行一次 @Test 测试方法:在这里可以测试期望异常和超时时间 @ignore 忽略的测试方法 @BeforeClass ...

    Junit_test.rar_JUnit_JUnit测试_junit工具 @test

    Junit是java中测试的必备工具,Junit_test这个程序是更好的实现对Junit的了解。帮助大家学习

    JUnitCategories:与 JUnit 4 @Category 注释一起使用的(小)类别集合

    JUnit 类别 JUnit 4.9 引入了一个很好的注释来对您的测试进行分类。 而 TestNG 选择为使用字符串 JUnit 类别使用类。 这比字符串更灵活,这在使用多模块 maven 项目时可能会很痛苦(有关更多详细信息,请参阅 JUnit ...

    junit-4.13.2的压缩包,JUnit是Java编程语言的单元测试框架,用于编写和可重复运行的自动化测试

    @SuiteClasses 用于套件测试 @BeforeClass @Before @After @AfterClass这些注解标注的方法又称测试的Fixture。 JUnit为所有原语类型、对象和数组(原语或对象)提供重载断言方法。参数顺序为预期值后接实际值。或者...

    反射和注解模拟JUnit4单元测试例子

    介绍如何利用反射和注解去简单的模拟JUnit4单元测试的使用,之所以选择JUnit4是...需要注意的是这里并不是完全的模拟,只是简单实现了一下Runner类和JUnit注解相关的工作流程。所以本文的主要目是介绍反射和注解的使用

    Junit单元测试内部机制解析

    Junit java单元测试内部机制解析

    Junit 5中@ParameterizedTest与@EnumSource结合使用

    今天小编就为大家分享一篇关于Junit 5中@ParameterizedTest与@EnumSource结合使用,小编觉得内容挺不错的,现在分享给大家,具有很好的参考价值,需要的朋友一起跟随小编来看看吧

    junit-extension:JUnit扩展

    junit-extension 背景 原生的Junit无法满足我们在自动化测试实践过程中的碰到一些需求,比如 ...以上三种注解和Junit build-in的注解@Test配合使用,示例如下 import org.junit.Test; import org.sdet.junit.extens

    JUnit5用户手册-中文

    junit-toolbox:使用JUnit 4编写自动化测试的有用类

    概述 JUnit工具箱提供了一些有用的类,用于使用... 尽管它扩展了WildcardPatternSuite您不必强制使用通配符模式,但也可以使用JUnit已知的@SuiteClasses批注列出子类。 -甲更换为JUnit运行Enclosed ,其执行与注释

    Junit中的基本注解(教学视频)

    Junit中的基本注解(教学视频) Junit中的基本注解,是必须掌握的。 @BeforeClass – 表示在类中的任意public static void方法执行之前执行 @AfterClass – 表示在类中的任意public static void方法执行之后执行 ...

    Transactional:Spring事务性Junit测试

    使用 tk-mybatis 的 demo 测试了 Spring 的事务 包含 @Transactional 注解所有的功能测试。

    在JUnit中使用@Rule测试文件和目录Java开发Ja

    在JUnit中使用@Rule测试文件和目录Java开发Java经验技巧共3页.pdf.zip

    Junit单元测试所需要的两个jar包

    1 Junit是什么 JUnit 是一个 Java 编程语言的单元测试框架。JUnit 在测试驱动的开发方面有很重要的发展,是起源于 JUnit 的一个统称为 xUnit 的单元测试框架之一。 2 单元测试概念 ...必须使注解@Test修饰

    java自定义注解\标签库\监听\junit简单测试

    java自定义 注解 annotation、标签库tag、监听listener、junit简单测试代码

    junit5.rar包含JUnit Platform + JUnit Jupiter + JUnit Vintage依赖jar包

    JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage,包含依赖包:junit-jupiter-5.5.1.jar,junit-jupiter-engine-5.5.1.jar,junit-jupiter-params-5.5.1.jar,junit-platform-launcher-1.5.1.jar,junit-...

    基于MyBatis注解的学生管理程序-ssm彻底掌握的练手项目

    1.包含项目所有需要的离线jar junit-4.7 log4j-1.2.16 mybatis-3.2.2-sources mybatis-3.3.0 mysql-connector-java-5.1.0-bin mysql-connector-java-8.0.26 2.项目使用注解开发,包含所有的mapper接口 3.还有所有的...

    Junit4使用方法

    测试类是包含一个或多个测试方法的类,而测试方法是使用@Test 注解的公共方法,不带任何参数,并且返回 void 类型。每个测试方法都运行于一个新的测试类实例上,以确保测试方法之间的独立性。 测试类 测试类是@...

    JUnit4基础文档

    本文档介绍了JUnit4的基础知识,包括单元测试的概念、JUnit4的HelloWorld示例、断言机制、注解使用、测试运行方式等。 单元测试的概念 单元测试是指对软件的最小单元进行测试,以确保其正确性和可靠性。单元测试...

    junit的jar包

    Files contained in junit4-4.8.2.jar: LICENSE.txt META-INF/MANIFEST.MF junit.extensions.ActiveTestSuite.class junit.extensions.RepeatedTest.class junit.extensions.TestDecorator.class junit.extensions...

Global site tag (gtag.js) - Google Analytics