Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Provide description patterns for Parameterized tests (addressing issues #24, #44 and #135) #145

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
5 participants

Addresses issues #24, #44 and #135

Usually when using parameterized tests, the reports display [0], [1], [2] for each run of the fixture and methodName[0], methodName[1], etc. for the actual tests. This creates the situation where you need to lookup the actual parameters in the sources to see what is the actual failure. A better approach would be if we could customize display names to contain more information about the scenario we are running.

Here (http://github.com/ddimtirov/junit/commit/b99a3) is a forked version with patched Parameterized runner that achieves this and a basic test for the functionality. I've also added a basic test for illustration.

The new feature works by allowing one to specify fixtureDescription and testDescription patterns to the Parameters annotation. This has the benefit that the formatting is kept close to the data and the default values are chosen to be backwards compatible, so there is no impact to the users that choose not to specify the patterns. See Javadoc for details.

neilsh commented Jul 12, 2011

This is a great patch, has anyone with commit access taken a look at it yet?

This is an excellent patch! Right now, Parameterized test can't even be 'extended' to add this; the only way to do this is to completely re-implement Parameterized.java, or change it to allow further extension.

Updated the title to make it clear that the patch is fixing open issues, rather than proposal of new functionality.

Contributor

stefanbirkner commented Feb 7, 2012

Could you please rebase to master.

Owner

dsaff commented Feb 24, 2012

@stefanbirkner, where is your tweaked version?

Contributor

stefanbirkner commented Feb 28, 2012

It is only in my mind, but I already have a bad conscience. I try to get it done as soon as possible.

Contributor

stefanbirkner commented Feb 29, 2012

I started to finish this pull request on https://github.com/stefanbirkner/junit/tree/Parameterized

stefanbirkner added a commit to stefanbirkner/junit that referenced this pull request Mar 2, 2012

Add names for parameterized tests. Fixes #24 and #44.
In order that you can easily identify individual test, you may provide
a name for the Parameters annotation.
 @Parameters(name="my test")
This name is allowed to contain placeholders, which are replaced at
runtime. The placeholders are
* {index} - the current parameter index
* {0} - the first parameter
* {1} - the second parameter
* ... - the other parameters
If you don't use the name parameter, then the current parameter index
is used as name.

Example:
When you use @Parameters(name="fib({0})={1}") with the Fibonacci
example, then you get test names like "fib(3)=2".

This feature is based on the work of Dimitar Dimitrov (pull request
#145).
Thank
you.
Contributor

stefanbirkner commented Mar 2, 2012

@dsaff It's ready.

ebruchez added a commit to orbeon/junit that referenced this pull request Mar 30, 2012

Add names for parameterized tests. Fixes #24 and #44.
In order that you can easily identify individual test, you may provide
a name for the Parameters annotation.
 @Parameters(name="my test")
This name is allowed to contain placeholders, which are replaced at
runtime. The placeholders are
* {index} - the current parameter index
* {0} - the first parameter
* {1} - the second parameter
* ... - the other parameters
If you don't use the name parameter, then the current parameter index
is used as name.

Example:
When you use @Parameters(name="fib({0})={1}") with the Fibonacci
example, then you get test names like "fib(3)=2".

This feature is based on the work of Dimitar Dimitrov (pull request
#145).
Thank
you.
Owner

dsaff commented Apr 2, 2012

@stefanbirkner, which is your pull request?

Contributor

stefanbirkner commented Apr 3, 2012

It is #393.

Owner

dsaff commented Apr 12, 2012

Fixed, I believe, by #393

@dsaff dsaff closed this Apr 12, 2012

@gensan gensan referenced this pull request Feb 12, 2014

Closed

Parameter's description #373

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment