JUnitParams
JUnitParams copied to clipboard
org.junit.runner.Description.fAnnotations array is null with junitparams parameterized junit tests
The Annotation[] array fAnnotations ( -> org.junit.runner.Description.fAnnotations) we need to be not null for failure reporting but it is unfortunately null when using junitparams parameterized junit 4.12 testcases.
We have derived our own TestCaseRule implementation from org.junit.rules.TestWatcher for doing custom evaluations with reporting purposes in every tetcase run context and before each any testcase code itself is being run by junit runner.
Within this relevant rule, which seems not to be working any more with junitparams, junit runner runs startingQuietly(description, errors) method in org.junit.rules.TestWatcher. This methods description parameter object shows up some unset fields, but only when invoked with junitparams runner annotated testclasses! Because this description object ( -> org.junit.runner.Decription) contains annotation data in any other testcase case and when called within any testcase context, but its field fAnnotations array is however always empty. In any other parameterized (with junit parameterized runner) or non parameterized junit testcase case the fAnnotations array size is at least 1at time of evaluation / runtime -> because the @Test annotation is always included, present at any testcase. Not so with junitparams even these annotations (@Test, @CustomizedAnnotation .. ) are always present!
We have customized Testcase Annotations and a rule to evaluate this we must annotate all our testcase methods with it, but which are unfortunately also not included in this fAnnotations array. For all other Junit Parameterized or NonParameterized Tests it works fine, all annotations which are found at the public testcase method will be found in that array again. Not so with JunitparamsRunner testcase annotations :( When running a parameterized junitparams Testcase it is beside other member fileds, which are set at this callstack time usually, always null, but for our failures reporting tool necessary not to be null, never!
Would like to keep this runner in our project but if the reporting issue due to null annotations in descriptions objects remains unsolved, other arguments may win...
We still use JUnitParams v.1.1.1
Do you have any idea for a fix or change or workaround?
Cheers!
Thank you kompacher for your fixes, thats great you have had a look into! Now, how can I test this hence no release update obviously was published yet. It seems so as if I shall adopt your changes and rebuild from the updated sources, right ? Cheers
Will this change furthermore come with one of the next version updates of this project? if so and depending on upwards compatbility of this change I'll decide which way to go
Dear @esvet
today I also fixed the broken ci-build in a different branch (see #159 for more info). I hope, that it gets merged fast and also the fix for the absent annotation info.
Hello,
I've just merged PR that fix broken build and we will try to review the main PR in next week.
Thanks for your contribution :)
If everything is ok with the PR we will release new version of JUnitParams since there is quite a lot of changes.
Dear @esvet
today I also fixed the broken ci-build in a different branch (see #159 for more info). I hope, that it gets merged fast and also the fix for the absent annotation info.
Dear @kompacher perfect, thanks a lot for your fix! It will let our framework report customly annotated testcase failures with junitparams running tests back again. Cheers
If everything is ok with the PR we will release new version of JUnitParams since there is quite a lot of changes.
Hello @woprzech, thank you for reviewing accordingly. A version update then will be meaningful to all users.
Any word on when a version with this will be released? I'm having the same issue where I have a JUnit rule which modifies test behaviour based on an annotation and the rule doesn't work properly because JUnitParams does not pass through the annotations
I am waiting for this fix to get merged in as well. Is this being maintained anymore?
I forked the repository, applied the fix myself and published it via Jitpack.
Repository: https://github.com/vinaysshenoy/JUnitParams Release: https://github.com/vinaysshenoy/JUnitParams/releases/tag/1.1.2 Maven artifact: https://jitpack.io/#vinaysshenoy/JUnitParams/1.1.2
Because of this issue, Allure annotations like @Issue
weren't working (not appearing in test reports).
https://github.com/Pragmatists/JUnitParams/pull/158 didn't fix it for me, but https://github.com/Pragmatists/JUnitParams/pull/168 did (with both #158 and #168 applied to latest v1.1.1 code). https://github.com/Pragmatists/JUnitParams/pull/160 seems to be almost the same as #168.