Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Tests annotated with @Test(expected = AssumptionViolatedException.class) will be marked as skipped instead of passing #1290

Closed
alb-i986 opened this issue May 12, 2016 · 5 comments
Labels
Milestone

Comments

@alb-i986
Copy link
Contributor

When using @Test(expected = AssumptionViolatedException.class) the test will actually be marked as skipped instead of passing, as if the AssumptionViolatedException were thrown up in the stack.
In fact that's what seems to happen: https://github.com/junit-team/junit4/blob/master/src/main/java/org/junit/internal/runners/statements/ExpectException.java#L22

I've found this bug while doing #1289, while inspecting our skipped unit tests.
See e.g. https://github.com/junit-team/junit4/blob/master/src/test/java/org/junit/tests/experimental/AssumptionTest.java#L80

But maybe this is actually working as expected. I mean, no one should ever expect AssumptionViolatedException. It can happen only to us, in our unit tests. Wherever we need to, we have to use a try/catch block instead.

@stefanbirkner You seem to have worked on assumptions quite a lot, can you please advise?

alb-i986 added a commit to alb-i986/junit that referenced this issue May 12, 2016
In case a test is expecting AssumptionViolatedException by using the attribute 'expected' of the @test annotation,
the test will actually be marked as skipped by IDEA and mvn, as if the AssumptionViolatedException had been thrown up in the stack.

See issue junit-team#1290
alb-i986 added a commit to alb-i986/junit that referenced this issue May 12, 2016
Tests annotated with `@Test(expected = AssumptionViolatedException.class)`
which throw AssumptionViolatedException should be marked as passing, not skipped.
@alb-i986
Copy link
Contributor Author

I think I got it. See #1291

alb-i986 added a commit to alb-i986/junit that referenced this issue May 14, 2016
Use a try/catch block instead of the attribute 'expected' of the @test annotation.
See bug junit-team#1290.
See discussion on junit-team#1289.
marcphilipp pushed a commit that referenced this issue May 14, 2016
Use a try/catch block instead of the attribute 'expected' of the @test annotation.
See bug #1290.
See discussion on #1289.
@adrianosimoes
Copy link

What's the status of this issue? Is it fixed?

@kcooney
Copy link
Member

kcooney commented Jan 22, 2017

@adrianosimoes there is a fix in #1291 by @alb-i986 but there were some issues with the tests and the pull languished. Alberto, any chance you can make the requested changes?

@alb-i986
Copy link
Contributor Author

Sure, I'll try to finish it asap.

@alb-i986
Copy link
Contributor Author

@kcooney I hope I haven't missed anything. Please check it out.
Thanks
--alb

kcooney pushed a commit that referenced this issue Feb 14, 2017
…d, not skipped (#1291)

Tests annotated with `@Test(expected = AssumptionViolatedException.class)`
which throw AssumptionViolatedException should be marked as passing, not skipped.

Fixes #1290
@kcooney kcooney modified the milestone: 4.13 Aug 6, 2017
@kcooney kcooney removed the 4.13 label Aug 6, 2017
sebasjm pushed a commit to sebasjm/junit4 that referenced this issue Mar 11, 2018
…d, not skipped (junit-team#1291)

Tests annotated with `@Test(expected = AssumptionViolatedException.class)`
which throw AssumptionViolatedException should be marked as passing, not skipped.

Fixes junit-team#1290
aristotle0x01 pushed a commit to aristotle0x01/junit4 that referenced this issue Jun 27, 2022
…d, not skipped (junit-team#1291)

Tests annotated with `@Test(expected = AssumptionViolatedException.class)`
which throw AssumptionViolatedException should be marked as passing, not skipped.

Fixes junit-team#1290
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants