如何将 TestSuites 与 Junit4 一起使用?
我似乎找不到任何有关如何执行此操作的文档来实际解释如何调用测试套件。到目前为止,我有这个:
package gov.hhs.cms.nlr.test;
import java.util.LinkedList;
import org.junit.runner.RunWith;
import gov.hhs.cms.nlr.test.marshalling.InquiryMarshallingTest;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
public class AllTests {
@RunWith(Suite.class)
@Suite.SuiteClasses({
SomeTestTest.class
SomeOtherTest.class
})
public class AllSuites {
// the class remains completely empty,
// being used only as a holder for the above annotations
}
}
但是我真的不明白如何运行这个...我想做的是进行所有给定的测试(每个测试,以及每个具有测试方法的类)并将它们全部放入 1 TestSuite然后调用它。
更新:我想知道如何在 (1) Eclipse 和 (2) hudson 和 (3) 中运行它strong>) 普通 java/JVM 调用(例如:java ...
)。谢谢。
I can't seem to find any documentation on how to do this that actually explains how to invoke the testsuite. So far I have this:
package gov.hhs.cms.nlr.test;
import java.util.LinkedList;
import org.junit.runner.RunWith;
import gov.hhs.cms.nlr.test.marshalling.InquiryMarshallingTest;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
public class AllTests {
@RunWith(Suite.class)
@Suite.SuiteClasses({
SomeTestTest.class
SomeOtherTest.class
})
public class AllSuites {
// the class remains completely empty,
// being used only as a holder for the above annotations
}
}
However I do not really understand how I can run this... What I want to do is take all given tests (each test, and from each Class which has Test methods) and put these all into 1 TestSuite and then invoke that.
Update: I would like to know how to run this in (1) Eclipse and (2) hudson and (3) plain java/JVM invocation (eg: java ...
). Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想你想要这样的东西:
更简单......它给你这个:
运行Eclipse
您可以像常规 JUnit 类一样运行它:运行 -> 运行方式 -> JUnit 测试。
在 Hudson 中运行
取决于您如何运行构建。蚂蚁?马文?
从 Java 运行
查看 JUnit 常见问题解答。基本上:
I think you want something like this:
Much simpler... It gives you this:
Running in Eclipse
You run it just like a regular JUnit class: Run->Run As->JUnit Test.
Running in Hudson
Depends how you are running your build. Ant? Maven?
Running from Java
Check out the JUnit FAQ. Basically: