[GRADLE-1290] Gradle Test stopped respecting @Ignore annotations on JUnit3 tests between 0.9-rc-3 and 0.9.1 Created: 05/Jan/11  Updated: 04/Jan/13  Resolved: 08/Mar/11

Status: Resolved
Project: Gradle
Affects Version/s: 0.9.1
Fix Version/s: 1.0-milestone-2

Type: Bug
Reporter: Kelly Robinson Assignee: Adam Murdoch
Resolution: Fixed Votes: 0

Attachments: Zip Archive ignoreUpgradeError.zip    

 Description   

I've been working with a mixed JUnit3/4 test suite(in the process of migrating from Ant to Gradle) and using @Ignore to manage temporarily broken tests. This was working fine until I upgraded to 0.9.1, at which point the @Ignore annotations are no longer being respected.
The attached project will fail when under 0.9.1 but will pass if you use the 0.9-rc3 wrapper.



 Comments   
Comment by Peter Niederwieser [ 05/Jan/11 ]

I'd say the current behavior is correct. Your test class qualifies as a JUnit 3 test class but not as a JUnit 4 one. Hence the @Ignore has no relevance. You could try to turn the class into a JUnit 4 test class, say by annotating it with @RunWith(JUnit4.class), or by annotating one method with @Test.

Comment by Kelly Robinson [ 06/Jan/11 ]

Unfortunately the suggested workaround of using @RunWith does not appear to work. My present alternative is to specify excludes on the Test task, which is what I was trying to avoid by applying @Ignore.

Comment by Kelly Robinson [ 14/Jan/11 ]

It should also be noted that this same configuration works for a maven project.

Comment by Casey Watson [ 14/Feb/11 ]

This should work if you remove the " extends TestCase" from your test.

It seems that extending from TestCase is causing it to be interpreted as a JUnit 3 test. Eclipse has the same issue with it's test runners.

If you need to use the methods from TestCase, I recommend using static imports to access them.

Comment by Adam Murdoch [ 08/Mar/11 ]

This is now 'fixed', in that the behaviour is now the same as it was in 0.9-rc-3. Whether or not this is a good behaviour is another question. It is provided by JUnit itself, not Gradle, so it's probably a reasonable option.

You should note that the @Ignore annotation only works on test classes. It does not (and did not) work on test methods. Again, this is what JUnit provides for JUnit 3 tests.

Generated at Wed Jun 30 11:51:48 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.