Junit - Ignore on class level doesn't work
Asked Answered
U

1

8

I'm using junit 4.12 and would like to ignore all test cases in class at once instead of adding ignore annotation before each method marked as test. According to documentation it is possible to add @Ignore on class level.

@Ignore
public class BasicOperationsTest extends TestBaseClass{

I did it like above but it doesn't work - all test methods are executed. When I add ignore before @Test method in this case annotation works and test is not executed.

Upspring answered 12/12, 2018 at 9:51 Comment(6)
Possible duplicate of How to get Junit 4 to ignore a Base Test Class?Leacock
Are you sure you are using org.junit.Ignore and not some other @Ignore annotation ?Calamander
I'm sure because I don't have any other Ignore to importUpspring
And it's not a duplicate because this solution from linked post doesn't workUpspring
How do you run the tests? Which commands do you use? Posting your TestBaseClass would also help.Outpour
Please post you TestBaseClassCoussoule
F
0

(Disclaimer: This is likely not OPs original issue, but it might be the issue of people who arrive here from google)

The problem for me was that I was using @Ignore with junit5, but in junit5/jupiter, the correct annotation is @Disabled, while @Ignore does nothing.

There is a subtle difference between the two in how the annotated tests get reported, but the usage is the same: https://www.softwaretestinghelp.com/junit-ignore-test-cases/
namely, Junit5&Disabled will count and report the number of ignored methods, while junit4&Ignore will count and report the number of ignored classes. But since both work to skip the test in the class, I don't think most people care.

Figurehead answered 1/3 at 11:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.