junit4 icon indicating copy to clipboard operation
junit4 copied to clipboard

Run a single test from a parameterized testclass by setting an environment variable.

Open ge0ffrey opened this issue 11 years ago • 5 comments

See this question on stackoverflow.

It seems there's no way to do this. If there's a way, it should be documented on the parameterized testclass wiki.

ge0ffrey avatar May 17 '13 12:05 ge0ffrey

There is no baked-in way to do this, so taking this as a feature request

dsaff avatar May 17 '13 14:05 dsaff

A org.junit.runner.manipulation.Filter could be used for this, couldn't it? That's how Eclipse is able to run individual tests or subtrees of tests as described in http://blog.moritz.eysholdt.de/2014/11/new-eclipse-junit-feature-run-subtrees.html

meysholdt avatar Nov 18 '14 16:11 meysholdt

@meysholdt Any chance that I can trigger that with a command line parameter (build-in JUnit)?

ge0ffrey avatar Nov 18 '14 16:11 ge0ffrey

Yes, in JUnit 4.12.

See https://github.com/junit-team/junit/pull/647

(Which is not yet in the release notes, hmm.)

On Tue, Nov 18, 2014 at 11:08 AM, Geoffrey De Smet <[email protected]

wrote:

@meysholdt https://github.com/meysholdt Any chance that I can trigger that with a command line parameter (build-in JUnit)?

Reply to this email directly or view it on GitHub https://github.com/junit-team/junit/issues/677#issuecomment-63495171.

dsaff avatar Nov 18 '14 16:11 dsaff

In the Eclipse Launch Configuration you can put the test's name into the "method name" filed. This works even though there is no actual method with that name. It's the name as returned by org.junit.runner.Description.getDisplayName().

If you don't want to launch your tests via Eclipse you could create your own Java-main-mehtod that is able to handle the parameters and reuse the filter implementations from Eclipse: http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/diff/org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/DescriptionMatcher.java?id=3b64020e89d0cefe9dca260edf6f9f633a03f4e9 http://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/diff/org.eclipse.jdt.junit4.runtime/src/org/eclipse/jdt/internal/junit4/runner/SubForestFilter.java?id=3b64020e89d0cefe9dca260edf6f9f633a03f4e9

meysholdt avatar Nov 18 '14 16:11 meysholdt