You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Phil Harvey <ph...@philharveyonline.com> on 2012/11/02 10:29:51 UTC

JUnit 4 upgrade

Hi,

I would like us to upgrade Qpid's Java test to use JUnit 4 rather than
Junit 3.  I believe this idea was floated a long time ago but never
progressed.

My motivations are:

- It opens the door to us replacing our bespoke test exclusion framework
with JUnit 4's Categories.  This would allow each test to state which
category it's in (eg SlowTest or Amqp010Only), so that you can run the full
test suite specifying which Category(s) to include or exclude.  Note that
it's hard to INclude a set of tests using our existing framework.

- JUnit 4 bundles Hamcrest, which allows you to make more succinct and
readable assertions.

- More succinct way of asserting that a specific exception was thrown
(@Test(expected=FooException.class)

- assertEquals now supports arrays

I have tried to do the upgrade and managed to get everything working.  Note
that this requires a change to almost all of our test classes because the
JUnit 4 way of specifying a test is to use @Test rather than extending
TestCase.

I propose that we do this upgrade in Qpid v0.22.  Initially we would leave
our test exclusion framework as-is, migrating to use JUnit 4 Categories in
a separate piece of work.

Would there be any objections to this?

Phil

Re: JUnit 4 upgrade

Posted by Phil Harvey <ph...@philharveyonline.com>.
Sure.  I've attached it to QPID-3025.  It's a work in progress but
everything compiles and (I think) all the tests pass.

I was planning to refactor QpidTestCase to be more JUnit4-ish before
creating the final patch, but haven't yet decided what is the best way to
do that.


On 2 November 2012 09:39, Rob Godfrey <ro...@gmail.com> wrote:

> Sounds good to me...
>
> Do you have a patch for this that can be reviewed right now (obviously we
> want to hold off applying it until after the 0.20 branch is created).
>
> -- Rob
>
> On 2 November 2012 10:29, Phil Harvey <ph...@philharveyonline.com> wrote:
>
> > Hi,
> >
> > I would like us to upgrade Qpid's Java test to use JUnit 4 rather than
> > Junit 3.  I believe this idea was floated a long time ago but never
> > progressed.
> >
> > My motivations are:
> >
> > - It opens the door to us replacing our bespoke test exclusion framework
> > with JUnit 4's Categories.  This would allow each test to state which
> > category it's in (eg SlowTest or Amqp010Only), so that you can run the
> full
> > test suite specifying which Category(s) to include or exclude.  Note that
> > it's hard to INclude a set of tests using our existing framework.
> >
> > - JUnit 4 bundles Hamcrest, which allows you to make more succinct and
> > readable assertions.
> >
> > - More succinct way of asserting that a specific exception was thrown
> > (@Test(expected=FooException.class)
> >
> > - assertEquals now supports arrays
> >
> > I have tried to do the upgrade and managed to get everything working.
>  Note
> > that this requires a change to almost all of our test classes because the
> > JUnit 4 way of specifying a test is to use @Test rather than extending
> > TestCase.
> >
> > I propose that we do this upgrade in Qpid v0.22.  Initially we would
> leave
> > our test exclusion framework as-is, migrating to use JUnit 4 Categories
> in
> > a separate piece of work.
> >
> > Would there be any objections to this?
> >
> > Phil
> >
>

Re: JUnit 4 upgrade

Posted by Rob Godfrey <ro...@gmail.com>.
Sounds good to me...

Do you have a patch for this that can be reviewed right now (obviously we
want to hold off applying it until after the 0.20 branch is created).

-- Rob

On 2 November 2012 10:29, Phil Harvey <ph...@philharveyonline.com> wrote:

> Hi,
>
> I would like us to upgrade Qpid's Java test to use JUnit 4 rather than
> Junit 3.  I believe this idea was floated a long time ago but never
> progressed.
>
> My motivations are:
>
> - It opens the door to us replacing our bespoke test exclusion framework
> with JUnit 4's Categories.  This would allow each test to state which
> category it's in (eg SlowTest or Amqp010Only), so that you can run the full
> test suite specifying which Category(s) to include or exclude.  Note that
> it's hard to INclude a set of tests using our existing framework.
>
> - JUnit 4 bundles Hamcrest, which allows you to make more succinct and
> readable assertions.
>
> - More succinct way of asserting that a specific exception was thrown
> (@Test(expected=FooException.class)
>
> - assertEquals now supports arrays
>
> I have tried to do the upgrade and managed to get everything working.  Note
> that this requires a change to almost all of our test classes because the
> JUnit 4 way of specifying a test is to use @Test rather than extending
> TestCase.
>
> I propose that we do this upgrade in Qpid v0.22.  Initially we would leave
> our test exclusion framework as-is, migrating to use JUnit 4 Categories in
> a separate piece of work.
>
> Would there be any objections to this?
>
> Phil
>