如何使用 RunWith 指定一套测试方法?

发布于 2024-11-27 18:45:24 字数 302 浏览 8 评论 0原文

我有类似以下内容:

@RunWith(AllTestsRunner.class)
public class AllTests {

}

其中 AllTestsRunner 是一个套件,它将返回与 AllTests 相同的包中的所有测试类。这工作得很好,但我希望有更细粒度的控制,而不仅仅是指定测试类是什么;我希望能够指定要运行的测试方法(某些测试方法用 @Category(Manual.class) 注释,这些方法不应在持续集成系统中运行) 。是否可以为 AllTests 指定 Runner?

I have something like the following:

@RunWith(AllTestsRunner.class)
public class AllTests {

}

in which AllTestsRunner is a Suite that will return all test classes within the same package as AllTests. This works fine, but I would like to have finer-grained control than to just specify what the test classes are; I would like to be able to specify the test methods to be run (some of the test methods are annotated with @Category(Manual.class) and these shouldn't be run in the continuous integration system). Is it possible to specify the Runner for AllTests?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猥琐帝 2024-12-04 18:45:24

使用:

@RunWith(Categories.class)
@Categories.ExcludeCategory(Manual.class)
@Suite.SuiteClasses(AllTests.class)
public class TestsToBeRunInCi {}

Use:

@RunWith(Categories.class)
@Categories.ExcludeCategory(Manual.class)
@Suite.SuiteClasses(AllTests.class)
public class TestsToBeRunInCi {}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文