Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flexible naming of parameterized tests #24

Closed
dsaff opened this issue Aug 10, 2009 · 7 comments
Closed

Flexible naming of parameterized tests #24

dsaff opened this issue Aug 10, 2009 · 7 comments

Comments

@dsaff
Copy link
Member

dsaff commented Aug 10, 2009

No description provided.

@JThoennes
Copy link

Is this a duplicate of issue 44?

@dsaff
Copy link
Member Author

dsaff commented Dec 8, 2009

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

@JThoennes
Copy link

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?

@ffray
Copy link

ffray commented Nov 2, 2011

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".

@JThoennes
Copy link

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).

@ffray
Copy link

ffray commented Nov 17, 2011

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

@dsaff
Copy link
Member Author

dsaff commented Nov 17, 2011

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

stefanbirkner added a commit to stefanbirkner/junit that referenced this issue Mar 2, 2012
.

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
junit-team#145).
Thank
you.
ebruchez pushed a commit to orbeon/junit that referenced this issue Mar 30, 2012
.

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
junit-team#145).
Thank
you.
@dsaff dsaff closed this as completed in 3a5c9f2 Apr 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants