junit4 icon indicating copy to clipboard operation
junit4 copied to clipboard

Flexible naming of parameterized tests

Open dsaff opened this issue 17 years ago • 7 comments

dsaff avatar Aug 10 '09 19:08 dsaff

Is this a duplicate of issue 44?

JThoennes avatar Dec 08 '09 14:12 JThoennes

Certainly resolving issue 44 would resolve this issue. I'm not clear if issue 44 covers any possible implementation of a better naming scheme.

dsaff avatar Dec 08 '09 14:12 dsaff

Basically, I would like to have the first parameter of a parameterized test to contain the name of the test. Then the @Parameters annotation could have a setting to indicate that the first parameter is the description to be taken instead of the number. This parameter defaults to disabled for backwards compatibility.

Alternatively, a static method to create names of test parameters would be more flexible.

Did you have a look at the offered patch in issue 44?

JThoennes avatar Dec 08 '09 14:12 JThoennes

I've created a little patch for this issue as I'm currently creating a larger set of tests using the Parameterized runner.

By adding an instance of a newly created class Parameterized.Name to each Object-array returned by the @Parameters method, getName and testName return the name instead of the fParameterSetNumber. So tests get named "[test-name]" and methods get named "test-method [test-name]". The patch is included in my fork at git://github.com/ffray/junit.git, branch "names".

ffray avatar Nov 02 '11 09:11 ffray

Thanks, Florian. This looks like a simple and flexible patch.

Hopefully, this will be integrated into the standard JUnit some day (not too far into the future).

JThoennes avatar Nov 02 '11 09:11 JThoennes

Could somebody please review Dimitars and my changes? Would be great to have this functionality in the official release.

ffray avatar Nov 17 '11 13:11 ffray

As I mentioned in a recent message to [email protected], my throughput on code reviews is currently very limited, and may be through the end of 2011. I'm sorry for the delay.

dsaff avatar Nov 17 '11 13:11 dsaff