为什么我的@BeforeClass方法运行? [英] Why isn't my @BeforeClass method running?
问题描述
我有以下的code:
@BeforeClass
公共静态无效setUpOnce()抛出InterruptedException的{
失败(LOL);
}
这要么是@Before,@After,@Test或@AfterClass方法的各种其它方法。
在启动时,因为它似乎它应该测试不会失败。有人可以帮我吗?
我的JUnit 4.5
该方法是在没有设置一个即时调用(),它被注释为@Before。
类DEF是:
公共类myTests扩展TestCase的{
不扩展TestCase,并在同一时间使用注释!
如果你需要创建一个测试套件与注释,使用RunWith注释,如:
@RunWith(Suite.class)
@ Suite.SuiteClasses({MyTests.class,OtherTest.class})
公共类AllTests中{
//空
}
公共类MyTests {//无法在这里延伸
@BeforeClass
公共静态无效setUpOnce()抛出InterruptedException的{
...
@测试
...
的(按约定:用大写字母类名)的
I have the following code:
@BeforeClass
public static void setUpOnce() throws InterruptedException {
fail("LOL");
}
And various other methods that are either @Before, @After, @Test or @AfterClass methods.
The test doesn't fail on start up as it seems it should. Can someone help me please?
I have JUnit 4.5
The method is failing in an immediate call to setUp() which is annotated as @before. Class def is :
public class myTests extends TestCase {
do NOT extend TestCase AND use annotations at the same time!
If you need to create a test suite with annotations, use the RunWith annotation like:
@RunWith(Suite.class)
@Suite.SuiteClasses({ MyTests.class, OtherTest.class })
public class AllTests {
// empty
}
public class MyTests { // no extends here
@BeforeClass
public static void setUpOnce() throws InterruptedException {
...
@Test
...
(by convention: class names with uppercase letter)
这篇关于为什么我的@BeforeClass方法运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!