Community
Participate
Working Groups
Hi colleagues, it is currently not possible to execute single test methods of a test class which is parameterized (and contains "@RunWith(Parameterized.class)" annotation). The JUnit result view shows message "Unrooted tests->initializationError". Reason is that the test requires a parameter value. If test is executed on class level everything is working fine and all tests with all parameter combinations are executed. If I have a failing test, I only want to launch a single test method what is currently not possible. Similar discussion can be found here: http://stackoverflow.com/questions/16517300/junit-parameterized-tests-how-do-i-run-only-1-specific-test-from-intellij-eclip Here a sample code to reproduce the problem: package com.sap.adt.cds.ddl.internal.parser.versions.v1; import java.util.Arrays; import java.util.List; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import org.junit.runners.Parameterized.Parameters; @RunWith(Parameterized.class) public class MyParameterizedUnitTest { private final String value; public MyParameterizedUnitTest(String name, String value) { this.value = value; } @Parameters(name = "{0}") public static List<Object[]> parserVersions() throws Exception { return Arrays.asList(new Object[][] {// { "v1", "paramValue1" }, // { "v2", "paramValue2" }, // { "v3", "paramValue3" } // }); } @Test public void test1() { Assert.assertTrue(this.value, true); } @Test public void test2() { Assert.assertTrue(this.value, true); } @Test public void test3() { Assert.assertTrue(this.value, true); } @Test public void test4() { Assert.assertTrue(this.value, true); } } Trigger java editor context menu "Run AS->JUnit test" on class level and all tests are executed. Trigger test on method level by selecting "method1" does not work. Please find attached a simple plugin containing an extension to the JUnit Run As context menu, which allows to trigger a simple test method of a prameterized junit test. Take a look into class JUnitParamLaunchShortcut which is a copy of JUnitLaunchShortcut with an additional method selectParamWithUi which allows to specifiy the paramValue via a simple dialog. The launch config is the modified so that test method is found and executed. Maybe it makes sense to introduce this logic into the JUnitLaunchShortcut class. The logic of showing the dialog should then be only done when the test class contains the @RunWith(Parameterized.class) annotation. This could be easily done from my point of view. Please let me know if you are interested; I am willing to help. With best regards, Tobias
Created attachment 242700 [details] extension of JUnitLaunchShortcut
The result when the test class is executed and when the test method is executed independently should be the same. Hence instead of contributing the new dialog to accept parameter value, the test method should read the parameters defined and execute the method accordingly. @Markus: Kindly share your thoughts. Yes, we welcome good quality patch. Refer https://wiki.eclipse.org/JDT_UI/How_to_Contribute to learn how to contribute a patch and to understand our coding guidelines.
see also bug 443498
*** Bug 446852 has been marked as a duplicate of this bug. ***
The contribution made in bug 443498 fixe this issue.
*** This bug has been marked as a duplicate of bug 443498 ***