Coder Social home page Coder Social logo

Comments (42)

JThoennes avatar JThoennes commented on July 21, 2024

How about this issue? The suggestions are good, when will you implement it / incorporate the patch?

Thanks, Jรถrg

from junit4.

JThoennes avatar JThoennes commented on July 21, 2024

See also issue 24 which talks about the same topic, but was entered by dsaff.

from junit4.

jjunit2010 avatar jjunit2010 commented on July 21, 2024

Any more news on when this fix might be implemented?

from junit4.

reccles avatar reccles commented on July 21, 2024

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.

Yishai avatar Yishai commented on July 21, 2024

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.

dbt avatar dbt commented on July 21, 2024

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.

ralfebert avatar ralfebert commented on July 21, 2024

See http://github.com/ralfebert/junit/commit/d5fedb0

from junit4.

JThoennes avatar JThoennes commented on July 21, 2024

Could this patch merged into the next JUnit release, please?

And when will the next release happen?

from junit4.

davidkarlsen avatar davidkarlsen commented on July 21, 2024

+1

from junit4.

kaipe avatar kaipe commented on July 21, 2024

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.

alexeyOnGitHub avatar alexeyOnGitHub commented on July 21, 2024

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:

http://code.google.com/p/migen/source/browse/trunk/java/src/uk/ac/lkl/common/util/testing/LabelledParameterized.java?r=3789

http://code.google.com/p/migen/source/browse/trunk/java/src/uk/ac/lkl/common/util/restlet/test/builder/ServerBuilderTest.java?r=3789

from junit4.

mmakowski avatar mmakowski commented on July 21, 2024

+1

from junit4.

soehalim avatar soehalim commented on July 21, 2024

+1

from junit4.

elygre avatar elygre commented on July 21, 2024

+1

from junit4.

binkley avatar binkley commented on July 21, 2024

+1

from junit4.

davidkarlsen avatar davidkarlsen commented on July 21, 2024

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.

sivaram-psg avatar sivaram-psg commented on July 21, 2024

+1

from junit4.

joelmheim avatar joelmheim commented on July 21, 2024

+1

from junit4.

stefanbirkner avatar stefanbirkner commented on July 21, 2024

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.

jonfreedman avatar jonfreedman commented on July 21, 2024

+1

from junit4.

stefanbirkner avatar stefanbirkner commented on July 21, 2024

I'm just waiting for pull request #348

from junit4.

bsbodden avatar bsbodden commented on July 21, 2024

+1

from junit4.

RaviH avatar RaviH commented on July 21, 2024

+1 (guessing that's the way to vote it up?)

from junit4.

Tibor17 avatar Tibor17 commented on July 21, 2024

+1

from junit4.

Jeanguitoune avatar Jeanguitoune commented on July 21, 2024

+1

from junit4.

yurodivuie avatar yurodivuie commented on July 21, 2024

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

slongoni avatar slongoni commented on July 21, 2024

+1

from junit4.

sharfah avatar sharfah commented on July 21, 2024

+1

from junit4.

cwhite102 avatar cwhite102 commented on July 21, 2024

+1

from junit4.

veger avatar veger commented on July 21, 2024

+1

from junit4.

java-artisan avatar java-artisan commented on July 21, 2024

+1

from junit4.

lbuchy avatar lbuchy commented on July 21, 2024

+1

from junit4.

mrmanc avatar mrmanc commented on July 21, 2024

+1

from junit4.

 avatar commented on July 21, 2024

+1

from junit4.

mariusx avatar mariusx commented on July 21, 2024

+1

from junit4.

jpfielding avatar jpfielding commented on July 21, 2024

+2

from junit4.

z3jiang avatar z3jiang commented on July 21, 2024

+1

from junit4.

avernet avatar avernet commented on July 21, 2024

+1

from junit4.

guyburton avatar guyburton commented on July 21, 2024

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

stefanbirkner avatar stefanbirkner commented on July 21, 2024

The feature is implemented. See #393.

@dsaff Could you please close the issue.

from junit4.

dsaff avatar dsaff commented on July 21, 2024

Done.

from junit4.

java-artisan avatar java-artisan commented on July 21, 2024

Many thanks indeed ! :-)

from junit4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.