Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I recently came across the same problem when using JUnit 4.3.1. I implemented a new class which extends Parameterized called LabelledParameterized. It has been tested using JUnit 4.3.1, 4.4 and 4.5. It reconstructs the Description instance using the String representation of the first argument of each parameter array from the @Parameters method. You can see the code for this at:</p> <p><a href="http://code.google.com/p/migen/source/browse/trunk/java/src/uk/ac/lkl/common/util/testing/LabelledParameterized.java?r=3789" rel="noreferrer">http://code.google.com/p/migen/source/browse/trunk/java/src/.../LabelledParameterized.java?r=3789</a></p> <p>and an example of its use at:</p> <p><a href="http://code.google.com/p/migen/source/browse/trunk/java/src/uk/ac/lkl/common/util/restlet/test/builder/ServerBuilderTest.java?r=3789" rel="noreferrer">http://code.google.com/p/migen/source/browse/trunk/java/src/.../ServerBuilderTest.java?r=3789</a></p> <p>The test description formats nicely in Eclipse which is what I wanted since this makes failed tests a lot easier to find! I will probably further refine and document the classes over the next few days/weeks. Drop the '?' part of the URLs if you want the bleeding edge. :-)</p> <p>To use it, all you have to do is copy that class (GPL v3), and change @RunWith(Parameterized.class) to @RunWith(LabelledParameterized.class) assuming the first element of your parameter list is a sensible label.</p> <p>I don't know if any later releases of JUnit address this issue but even if they did, I can't update JUnit since all my co-developers would have to update too and we have higher priorities than re-tooling. Hence the work in the class to be compilable by multiple versions of JUnit.</p> <hr> <p><strong>Note:</strong> there is some reflection jiggery-pokery so that it runs across the different JUnit versions as listed above. The version specifically for JUnit 4.3.1 can be found <a href="http://code.google.com/p/migen/source/browse/trunk/java/src/uk/ac/lkl/common/util/testing/LabelledParameterized.java?r=3775" rel="noreferrer">here</a> and, for JUnit 4.4 and 4.5, <a href="http://code.google.com/p/migen/source/browse/trunk/java/src/uk/ac/lkl/common/util/testing/NewLabelledParameterized.java?r=3777" rel="noreferrer">here</a>.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload