首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >JUnit 5和测试套件

JUnit 5和测试套件
EN

Stack Overflow用户
提问于 2021-09-21 13:22:29
回答 1查看 2.7K关注 0票数 1

我们有一个纯JUnit-5项目,我们想分类我们的单元测试。

要做到这一点,我理解的是我们需要包括JUnit-4 @RunWith(JUnitPlatform.class)

代码语言:javascript
复制
import org.junit.platform.runner.JUnitPlatform;
import org.junit.platform.suite.api.IncludeTags;
import org.junit.platform.suite.api.SelectPackages;
import org.junit.runner.RunWith;

@RunWith(JUnitPlatform.class)
@SelectPackages("my.project.domain")
@IncludeTags("long-running-test") 
public interface LongRunningTestSuite {}

在Intellij中,我可以毫无问题地运行所有或仅仅测试套件,但是在使用maven执行时会出现一个错误:

  • in Intellij-Idea一些测试用例失败了控制台上的
  • 我有一个无休止的循环

这没什么用:

代码语言:javascript
复制
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <skip>false</skip>
        <excludes>
            <exclude>**/*TestSuite.java</exclude>
        </excludes>
        <includes>
            <include>**/*Test.java, **/*IT.java</include>
        </includes>
    </configuration>
</plugin>

如果我只是删除所有的XyzTestSuite.java类,那么maven构建就成功了。我还试过<exclude>my.project.domain.testsuite</exclude>

排除缝不起作用。为什么?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-09-21 13:49:18

JUnitPlatform已经被否决了。

相应的新特性是JUnit平台套件引擎:https://junit.org/junit5/docs/current/user-guide/index.html#junit-platform-suite-engine

但是,如果仅仅是对测试进行分类,那么标记就足够了,这就足够了:https://junit.org/junit5/docs/current/user-guide/index.html#writing-tests-tagging-and-filtering

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69269641

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档