microsoft / microsoft/vscode-java-test

Wrong test name displayed for JUnit 4 parameterized test

Open
#1,562 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-triaged bug help wanted investigating junit low-priority ui
Dominant language
TypeScript
Stars
340
Forks
173
Avg merge
1d 19h
Merged PRs (30d)
18

Description

Sample code:

@RunWith(Parameterized.class)
public class ParameterizedWithNameTest {

    @Parameter
    public int expected;

    @Parameters(name = "{index}: expect={0}")
    public static Collection<Object> data() {
        // If using the name annotation param and one of the inputs has a rounded
        // bracket, e.g. @Parameters(name = "test({index})"), then the test name needs
        // to be properly handled.
        return Arrays.asList(1, 2, "normalString", "()", "(()");
    }

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

Run the test will get:

image

Root cause is that here it's just check the position of (:
https://github.com/microsoft/vscode-java-test/blob/e7c10db82a0cbd0d8d11515fe51153a2e00cb584/src/runners/junitRunner/JUnitRunnerResultAnalyzer.ts#L457

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/runners/junitRunner/JUnitRunnerResultAnalyzer.ts at the linked code near line 457. Reproduce the JUnit 4 parameterized test with inputs such as "()" and "(()", then inspect how the displayed name is derived from the parameterized name. Done means names containing rounded brackets are handled correctly without breaking the other sample inputs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, typescript
Domain
testing-qa
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.