Comments (42)
How about this issue? The suggestions are good, when will you implement it / incorporate the patch?
Thanks, Jรถrg
from junit4.
See also issue 24 which talks about the same topic, but was entered by dsaff.
from junit4.
Any more news on when this fix might be implemented?
from junit4.
There appears to be some demand for this simple feature outside as well: http://stackoverflow.com/questions/650894/change-test-name-of-parameterized-tests
from junit4.
As an additional (simpler) suggestion, how about just changing
@OverRide protected String testName(final FrameworkMethod method) {
return String.format("%s%s", method.getName(),
Arrays.toString(fParameterList.get(fParameterSetNumber)));
}
from junit4.
From my deployment experience (I forked Parameterized internally to my project and extended it with similar functionality), using toString or non-static testName() functions were suboptimal, and using a fixed portion of the parameters list (either the first parameter or all of them) was also not useful. My preferred solution was to support an annotated static method that took the same arguments as the constructor and returned a string, and fall back to the test number if that didn't work.
I'm happy to get the (fairly trivial) patch open sourced if that would help solve this problem.
Thanks,
-dave
from junit4.
See http://github.com/ralfebert/junit/commit/d5fedb0
from junit4.
Could this patch merged into the next JUnit release, please?
And when will the next release happen?
from junit4.
+1
from junit4.
I have released a framework that offers a solution to this problem:
http://callbackparams.org The test-class runner that will probably solve most cases where this problem arises is ...
http://callbackparams.org/project/api-javadoc/org/callbackparams/junit4/EnumRunner.html ... and for more complex cases the rest of the framework has a lot to offer.
The key feature in regard to this issue is that tests are named by the overridden method java.lang.Object#toString(), which for enum-constants happen to return the name of the constant. If the enum-constant name won't do it is of course still possible to override java.lang.Object#toString() explicitly for those constants that need more verbose test-names.
Anyhow, I think that a solution that does not rely on the toString()-method is simply not very elegant.
from junit4.
the source code posted here worked perfectly
http://stackoverflow.com/questions/650894/change-test-name-of-parameterized-tests
here are the direct links to the source code:
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
Cmon! Why can't you apply this Kent? You even have ready patches and the issue is ancient. Isn't good naming part of cleancode and TDD practices - or do we simply have to dump junit for testng?
from junit4.
+1
from junit4.
+1
from junit4.
I like Dave's idea of a label method. It may look like
@Label
public String labelForParameters(Object... parameters) {
...
}
Hopefully there's time today or tomorrow evening to implement this.
from junit4.
+1
from junit4.
I'm just waiting for pull request #348
from junit4.
+1
from junit4.
+1 (guessing that's the way to vote it up?)
from junit4.
+1
from junit4.
+1
from junit4.
+1. We've started keeping our own version of Parameterized to fix this problem, but it would be great to have this supported from the source.
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+1
from junit4.
+2
from junit4.
+1
from junit4.
+1
from junit4.
+1 we have used a fork of Parameterized to implement this feature. We have also made the TestClassRunnerForParameters protected, and it is created by a protected method to allow extension of Parameterized within another implementation of Suite.
from junit4.
The feature is implemented. See #393.
@dsaff Could you please close the issue.
from junit4.
Done.
from junit4.
Many thanks indeed ! :-)
from junit4.
Related Issues (20)
- gh
- SpringBoot test failure in circleci HOT 3
- Confusing problem... get differernt result between `main method` and `test method` HOT 7
- Compilation error in org.junit.runner.Result - ObjectInputStream.GetField.get(name, object) throws ClassNotFoundException
- Update to hamcrest 2.2 HOT 16
- Test case grouping - Run subset of test cases depending on specific environment variables HOT 8
- Thread context classloader not reset between tests HOT 1
- Cross site scripting HOT 1
- How to test Redis Time out exception for @Cacheable method with Junit+ Spring integration test HOT 3
- Make Assert failNotEquals public HOT 1
- Assert error messages are not clear HOT 2
- Exception handling of suite() method breaks Jenkins JUnit test history reporting HOT 6
- Add support for "dynamic" default runner selection via system property HOT 8
- When will a new version of junit be released? HOT 1
- JUnitCore could not invoke test HOT 1
- Strange links on "Download and Install" page HOT 1
- junit-4.13.2 compilation error with java 21 HOT 4
- Treat org.opentest4j.TestAbortedException the same as AssumptionViolatedException HOT 4
- Which junit version supports Java 17 ? HOT 2
- Assert check not consistent HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from junit4.