gpt4 book ai didi

regex - 迁移: JUnit 3 to JUnit 4: TestSuite

转载 作者:行者123 更新时间:2023-12-02 22:25:05 25 4
gpt4 key购买 nike

我最近使用 JUnit 3,但我决定迁移到 JUnit 4。现在我面临以下问题:

我使用带有 JUnit 3 的 TestSuite,其中运行了名称与“*TestMe.java”等模式匹配的所有 java-Testclass。

我有一百个这样命名的测试。

现在,使用 JUnit 4,我必须明确命名它们才能在 TestSuite 中调用它们。

@RunWith(Suite.class)
@Suite.SuiteClasses(
{
FirstTestMe.class,
SecondTestMe.class,
ThirdTestMe.class,

})
public class TestMe
{
/**
* Constructor.
*/
private TestMe()
{
super();
}
}

这真的很不舒服,我可能会忘记列出一些测试。另外,当我创建一个新的时,我必须将其添加到那里。

是否有任何解决方案如何使用正则表达式或其他内容调用这些测试类?

另外,还有一个问题:每个不是测试但可能在测试类中使用的方法都必须用 @Ignore 进行注释?我运行这些测试类没有任何错误,所以我想这是没有必要的?

最佳答案

您可能想看看帖子migrate-tests-from-junit-3-to-junit-4其中讨论了您想要的内容。

看看是否Dynamically create a Test Suite in JUnit 4Run all tests in Junit 4有帮助。

关于regex - 迁移: JUnit 3 to JUnit 4: TestSuite,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9266204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com