Skip to content

@Ignore not taking effect when used on an overriden test method #695

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
triceo opened this issue Jun 16, 2013 · 5 comments
Open

@Ignore not taking effect when used on an overriden test method #695

triceo opened this issue Jun 16, 2013 · 5 comments

Comments

@triceo
Copy link

triceo commented Jun 16, 2013

When I have a test in super class which I then override in subclass and add the Ignore annotation to this overriden test, the test is run anyway. (Not ignored.)

Reproducer for the issue can be found here:
https://github.com/triceo/junit/commit/14e5d37f09d7c822d93a172481796524017735ee

@kcooney
Copy link
Member

kcooney commented Jun 16, 2013

The method in the subclass is not annotated with @test

@triceo
Copy link
Author

triceo commented Jun 16, 2013

If the method didn't execute at all, because it's not a @test, I would understand. However, the method executes (even though it's not annotated as @test), and thus @ignore should in my opinion apply as well.

@kcooney
Copy link
Member

kcooney commented Jun 16, 2013

The method is considered a test because the base class method is annotated
with @test (so the base class version of the method is examined). The base
class method is not annotated with @ignore so it is not ignored.

@dsaff
Copy link
Member

dsaff commented Jun 17, 2013

The subclass method does need to be annotated with "@test" in order to be considered to override the superclass method for JUnit's purposes (we basically have to re-implement "overriding" for our odd reflection-based execution model.)

I think this is probably a good rule to enforce, but I can understand the confusion it causes in this case. I might consider adding a validation check that would flag an error if a superclass method with @test matches the name of a subclass method without @test. Would that have solved your problem?

@triceo
Copy link
Author

triceo commented Jun 17, 2013

Yes, that would've worked as well.

ojw28 pushed a commit to google/ExoPlayer that referenced this issue Dec 23, 2020
With @ignore but not @test the method is still executed by JUnit:
junit-team/junit4#695

PiperOrigin-RevId: 348009981
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants