我想执行一个来自主类的测试。我曾尝试:使用JUnitCore和Spring一起使用
public static void main(String[] args) {
JUnitCore runner = new JUnitCore();
runner.run(TestClass.class);
}
和
public static void main(String[] args) {
JUnitCore.main(TestClass.class.getName());
}
然而,本次测试使用Spring框架和豆类都没有加载。 我的测试类是这样的:
@NoDataSet
@ContextConfiguration(locations = { "/.../xxx-beans.xml", "/.../yyy-beans.xml",
"..." }, inheritLocations = false)
@RunWith(SpringJUnit4ClassRunner.class)
public class TestClass extends AbstractTransactionalJUnit4SpringContextTests {
@BeforeClass
public static void beforeClass() {
// some config
}
@Test
public void testSomething() {
// testsomething
}
}
我使用了很多豆子,所以我不能手动加载豆。
有没有另外一种方法开始这个测试?
按照[JUnitCore-文档】(http://junit.sourceforge.net/javadoc/org/junit/runner/JUnitCore。 HTML),我们不应该使用这种方法。无论如何感谢 – user969039 2013-02-19 13:24:09