org.junit.Assert. 已弃用junit.framework.Assert
我的问题是如果我的JUnit类没有扩展一个TestCase我该如何在Eclipse中创建一个Test Suite?
当我尝试在Eclipse中创建新的测试套件时,我的类没有出现在选择框中,我想这是因为它们不扩展一个TestCase 。
我认为,新的org.junit我可以使用注释,而不是扩展TestCase
org.junit.Assert. has deprecated junit.framework.Assert
My question is how do I create a Test Suite in Eclipse if my JUnit classes do not extend a TestCase?
When I try to create new Test Suite in Eclipse my classes do not appear in the select box and I imagine this is because they don't extend a TestCase.
I thought that with the new org.junit I can just use annotation and not extend TestCase
最满意答案
以下代码将创建一个包含Junit4的测试套件。 然后,您可以在Eclipse中将其作为Junit测试用例运行。 很显然,TestClasses需要包含用@Test注解的方法,否则没有测试会实际运行该套件。
import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({TestClass1.class, TestClass2.class}) public class TestSuite { //nothing }The following code will create a test suite with Junit4. You can then just run this in Eclipse as a Junit test case. Obviously the TestClasses need to contain methods annotated with @Test otherwise no tests will actually run for the suite.
import org.junit.runners.Suite; @RunWith(Suite.class) @Suite.SuiteClasses({TestClass1.class, TestClass2.class}) public class TestSuite { //nothing }更多推荐
TestCase,junit,Eclipse,扩展,电脑培训,计算机培训,IT培训"/> <meta name="des
发布评论