Categories + Parameterized still does not work in 4.9 final (#74 reopen?)
See original GitHub issueI am afraid the categories + parameterized duo still does not work properly with fresh junit 4.9 final, yet after #74 changes the feedback is much better than messageless NPE. Note that the test class has @Category annotation on class level. The stacktrace:
java.lang.Exception: Category annotations on Parameterized classes are not supported on individual methods.
at org.junit.runners.model.InitializationError.<init>(InitializationError.java:30)
at org.junit.experimental.categories.Categories.assertNoDescendantsHaveCategoryAnnotations(Categories.java:179)
at org.junit.experimental.categories.Categories.assertNoCategorizedDescendentsOfUncategorizeableParents(Categories.java:171)
at org.junit.experimental.categories.Categories.assertNoCategorizedDescendentsOfUncategorizeableParents(Categories.java:173)
at org.junit.experimental.categories.Categories.<init>(Categories.java:156)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:35)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:32)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:25)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:41)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:31)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Code snippets - imports omitted for brevity, I can provide you with a complete eclipse/ant project if necessary. The problematic test:
@RunWith(Parameterized.class)
@Category(SampleCategory.class)
public class AdditionTest {
static final Integer[][] SCENARIOS = new Integer[][] { { 2, 2, 4 },
{ -2, 2, 0 }, { -4, -1, -5 }, };
int one, two, expectedSum;
public AdditionTest(int one, int two, int expectedSum) {
super();
this.one = one;
this.two = two;
this.expectedSum = expectedSum;
}
@Test
public void addAndSeeWhatHappens() throws Exception {
assertEquals("sum", expectedSum, one + two);
}
@Parameters
public static Collection<Integer[]> regExValues() {
return Arrays.asList(SCENARIOS);
}
}
The suite:
@RunWith(Categories.class)
@IncludeCategory(SampleCategory.class)
@SuiteClasses({ AdditionTest.class, MultiplicationTest.class })
public class SampleSuite {
}
When I comment out the @Category in AdditionTest, the suite runs MultiplicationTest fine (it contains “normal” test methods, also has class-level @Category).
Issue Analytics
- State:
- Created 12 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
When using JUnit's @Parameterized, can I have some tests ...
I use @Parameterized in many cases to run tests on a number of permutations. This works very well and keeps the test-code itself...
Read more >PyCharm 2022.3 EAP 1 (223.4884.74 build) Release Notes
No subsystem Task PY‑56077
Code Insight Bug PY‑55920
Console Usability PY‑51667
Bug PY‑53529
Read more >National Emissions Standards for Hazardous Air ... - Federal Register
The 1997 NESHAP for primary aluminum reduction plants incorporates new source performance standards for potroom groups. These emission limits are listed in ...
Read more >DBISAM Version 4 Manual for RAD - Elevate Software
This was done to fix a bug in the parsing of parameters in SQL statements in the TParams object, as well as to...
Read more >Programming with STEP 7 - Siemens Industry Online Support
indicates that property damage can result if proper precautions are not taken. ... 26.3.4.9 Transferring to IN_OUT Parameters of a Function Block ....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@1hanymhajna thanks for the quick response.
We can possibly look into fixing this, but in JUnit5 we will support parameterized tests without a special runner. I suggest filing a bug to ensure JUnit5 supports categories + parameters.
it’s still not working for me , i’m using junit 4.12