Alex Rivera | Logout

What can cause JUnit to disregard @Ignore annotations?

Asked 2011-06-02T17:26:32.960
38

I just used MyEclipse to automatically generate some JUnit test cases. One of the generated methods looks like this:

@Ignore("Ignored") @Test
public void testCreateRevision()
{
    fail("Not yet implemented"); // TODO
}

I added the @Ignore annotation manually. However, when I run the test, JUnit lists that method, and others like it, under "failures," rather than ignoring them (related: What's the difference between failure and error in JUnit?). And it displays the "Not yet implemented" message instead of the "Ignored" message. Clearly, fail() must be getting called, and therefore, the @Ignore assertion is not working.

What's going on here? Is there a setting I need to enable for this to work?

EDIT :
Things I have considered/tried so far:

  • I am using JUnit 4, so it's not a version problem.
  • I am importing org.junit.Ignore, so it's not a case of the wrong Ignore being used.
  • I have tried using @Ignore alone, @Ignore @Test and @Ignore("message") @Test; all fail.

EDIT 2 :
I created the tests with MyEclipse, via New > Other; Java > JUnit > JUnit Test Case; New JUnit 4 test, and the library in my build path is JUnit 4. I'm building with ant and actually running the case with MyEclipse.

Edit
Report

1 Answer

2

Are you sure the test classes were recompiled?

It's a quite common problem, that the recompilation fails because there was typo somewhere in the sources (like a missing semicolon), and the IDE does not tell you that compiling failed.

Try deleting the target/test-classes folder.

answered 2011-06-02T17:47:45.433

Your Answer