Looking at the fix
<https://github.com/junit-team/junit4/commit/37a8aaba8a817b4bebbeebcd645d304601a0c8f0>
a little bit, I think we can work around this with the current version of
junit with something like this. We just need to create our own runner
factory that will return the correct annotations.

@Category(UnitTest.class)
@RunWith(Parameterized.class)
@UseParametersRunnerFactory(MyRunnerFactory.class)
public class YourTest {...}


public class MyRunnerFactory implements ParametersRunnerFactory {

    @Override public Runner createRunnerForTestWithParameters(final
TestWithParameters test)
      throws InitializationError
    {
      return new BlockJUnit4ClassRunnerWithParameters(test) {
        @Override protected Annotation[] getRunnerAnnotations() {
          return getTestClass().getAnnotations();
        }
      };
    }
}

-Dan



On Tue, May 10, 2016 at 3:58 PM, Dan Smith <[email protected]> wrote:

> If we switch to a snapshot release, that means the version of junit will
> be a moving target, right? So if someone checks a breaking change into
> junit all of our builds will fail. Or worse, not fail. I'm not sure if
> that's state we want to be in.
>
> -Dan
>
> On Tue, May 10, 2016 at 2:54 PM, Jens Deppe <[email protected]> wrote:
>
>> Kirk recently found that test classes annotated with both @Category and
>> @Parameterized (both standard JUnit annotations) result in tests being
>> skipped [1]
>>
>> It appears that JUnit 4.13-SNAPSHOT fixes the issue.
>>
>> Does anyone have any aversion to using a 'SNAPSHOT' release for junit?
>>
>> An alternative is to use JunitParamsRunner [2]. However I've already run
>> into a problem with it in that params are not exposed to @Before methods
>> which means that any @Before code, using parameters, would need to be
>> explicitly called from every test method.
>>
>> Thoughts? Comments?
>>
>> --Jens
>>
>>
>> [1] https://issues.apache.org/jira/browse/GEODE-1350
>> [2] http://pragmatists.github.io/JUnitParams/
>>
>
>

Reply via email to