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

Attempting to rerun failing JUnit 4 Parameterized tests in IDEA fails #1604

Open
Panthro opened this issue Apr 12, 2019 · 3 comments
Open

Attempting to rerun failing JUnit 4 Parameterized tests in IDEA fails #1604

Panthro opened this issue Apr 12, 2019 · 3 comments

Comments

@Panthro
Copy link

Panthro commented Apr 12, 2019

When I have a test with

@Parameterized.Parameters(name = "{1} : {0}")

If I try to rerun failed tests in Intellij Idea, then I get:

java.lang.Exception: No tests found matching Tests from org.junit.runner.Request$1@5ae50ce6

	at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:40)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:49)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

If I leave the @Parameterized.Parameters without name it works, any idea?

Found a Junit5 related issue, junit-team/junit5#1386

Junit version 4.12, can this be related or should I open another issue?

@Panthro Panthro changed the title launch failed tests with parametrized test Attempting to rerun failing JUnit 4 Parameterized tests in IDEA fails Apr 12, 2019
@panchenko
Copy link
Contributor

panchenko commented Apr 12, 2019

In IDEA 2019.1 it works for me. As suggested in the mentioned junit5 issue - please try a newer version of IDEA

@RunWith(Parameterized.class)
public class Issue1604 {
    @Parameterized.Parameters(name = "{1} : {0}")
    public static List<Object[]> params() {
        return Arrays.asList(
                new Object[]{ "A", 1 },
                new Object[]{ "B", 2 }
        );
    }

    @Parameterized.Parameter(0)
    public String first;

    @Parameterized.Parameter(1)
    public Integer second;

    @Test
    public void test() {
        assertEquals((Integer) 1, second);
    }
}

@stefanbirkner
Copy link
Contributor

@Panthro Which version of IntelliJ IDEA are you using?

@felix9
Copy link

felix9 commented Aug 18, 2021

I just ran into this problem.

"Rerun Failed Tests" fails if the parameterized test name has a "/" in it.

@RunWith(Parameterized.class)
public class ParaTest {
	@Parameterized.Parameters(name = "{0}")
	public static List<Object[]> params() {
		return Arrays.asList(
			new Object[]{ "a/1" },
			new Object[]{ "b/2" }
		);
	}

	@Parameterized.Parameter
	public String name;

	@Test
	public void test() {
		assertEquals("x", name);
	}
}

IntelliJ IDEA 2021.2 (Community Edition)
Build #IC-212.4746.92, built on July 27, 2021
Runtime version: 11.0.11+9-b1504.13 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 10.15.7
GC: ParNew, ConcurrentMarkSweep
Memory: 1979M
Cores: 16
Kotlin: 212-1.5.10-release-IJ4746.92

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