You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by Jens Deppe <je...@apache.org> on 2016/05/10 21:54:53 UTC

Moving to JUnit 4.13-SNAPSHOT

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/

Re: Moving to JUnit 4.13-SNAPSHOT

Posted by Jens Deppe <jd...@pivotal.io>.
Thanks Dan - that's great.

On Tue, May 10, 2016 at 6:11 PM, Kirk Lund <kl...@pivotal.io> wrote:

> Let's talk more about the workaround tomorrow to determine how easy and
> reusable that might be.
>
> We could also reach out to the JUnit community to get a possible ETA for
> releasing 4.13.
>
> -Kirk
>
>
> On Tue, May 10, 2016 at 4:48 PM, Mark Bretl <as...@gmail.com> wrote:
>
> > I agree with Dan that depending on a SNAPSHOT version is probably not the
> > best, especially when it is a major part running our tests. This could
> have
> > problems when no developers change anything but JUnit releases a new
> > snapshot and the nightly build uses the newest release resulting in new
> > failures.
> >
> > I would be in favor of a workaround, if we have consensus, until the
> actual
> > 4.13 release.
> >
> > --Mark
> >
> > On Tue, May 10, 2016 at 4:26 PM, Dan Smith <ds...@pivotal.io> wrote:
> >
> > > 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 <ds...@pivotal.io> 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 <je...@apache.org>
> > > 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/
> > > >>
> > > >
> > > >
> > >
> >
>

Re: Moving to JUnit 4.13-SNAPSHOT

Posted by Kirk Lund <kl...@pivotal.io>.
Let's talk more about the workaround tomorrow to determine how easy and
reusable that might be.

We could also reach out to the JUnit community to get a possible ETA for
releasing 4.13.

-Kirk


On Tue, May 10, 2016 at 4:48 PM, Mark Bretl <as...@gmail.com> wrote:

> I agree with Dan that depending on a SNAPSHOT version is probably not the
> best, especially when it is a major part running our tests. This could have
> problems when no developers change anything but JUnit releases a new
> snapshot and the nightly build uses the newest release resulting in new
> failures.
>
> I would be in favor of a workaround, if we have consensus, until the actual
> 4.13 release.
>
> --Mark
>
> On Tue, May 10, 2016 at 4:26 PM, Dan Smith <ds...@pivotal.io> wrote:
>
> > 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 <ds...@pivotal.io> 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 <je...@apache.org>
> > 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/
> > >>
> > >
> > >
> >
>

Re: Moving to JUnit 4.13-SNAPSHOT

Posted by Mark Bretl <as...@gmail.com>.
I agree with Dan that depending on a SNAPSHOT version is probably not the
best, especially when it is a major part running our tests. This could have
problems when no developers change anything but JUnit releases a new
snapshot and the nightly build uses the newest release resulting in new
failures.

I would be in favor of a workaround, if we have consensus, until the actual
4.13 release.

--Mark

On Tue, May 10, 2016 at 4:26 PM, Dan Smith <ds...@pivotal.io> wrote:

> 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 <ds...@pivotal.io> 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 <je...@apache.org>
> 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/
> >>
> >
> >
>

Re: Moving to JUnit 4.13-SNAPSHOT

Posted by Dan Smith <ds...@pivotal.io>.
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 <ds...@pivotal.io> 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 <je...@apache.org> 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/
>>
>
>

Re: Moving to JUnit 4.13-SNAPSHOT

Posted by Dan Smith <ds...@pivotal.io>.
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 <je...@apache.org> 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/
>