apache / apache/netbeans

in maven project rerun tests from test results window creates wrong command line when DisplayName enabled

Open
#7,146 0 comments 0 reactions 0 assignees View on GitHub
Java kind:bug Maven tests
Dominant language
Java
Stars
3.1k
Forks
935
Avg merge
2d 3h
Merged PRs (30d)
17

Description

### Apache NetBeans version

Apache NetBeans 21

### What happened

When re-running a (failed) test from the test-results-window, the test is not run.

Looking into the Output-run window we see the command line that is built is incorrect.
```shell
mvn -Dtest=codestripper.ArchiverTest#test -nsu -Psurefire-nb process-test-classes surefire:test
^^^
+ should be testAssignmentFile in this case
```
The command line above is abbreviated to the relevant part.

![image](https://github.com/apache/netbeans/assets/4232630/2e3323af-9ecb-4381-84a0-fdc288936ef0)

Run again with DisplayName disabled runs correctly.
That is then a workaround.

### Language / Project Type / NetBeans Component

java test runner

### How to reproduce

In Junit 5 test, add DisplayNames
Then run the tests. You can select rerun on a displayed line, but rerun does not find any test because the command line constructed is broken. It replaces the test method name or assumes or computes it to be test.

### Did this work correctly in an earlier version?

No / Don't know

### Operating System

Linux Ubuntu 22.04 LTS

### JDK

openjdk 21.0.1

### Apache NetBeans packaging

Apache NetBeans binary zip

### Anything else

Reproducable. So always when not aware of the needed workaround.

### Are you willing to submit a pull request?

No

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the JUnit 5 case in the NetBeans test-results window with DisplayName enabled, then inspect the Maven command shown in the Output-run window when rerunning a failed test. Trace how the displayed test name becomes the -Dtest value; done means rerun uses the actual method name, such as testAssignmentFile, and finds the test.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.