Skip to content

Inconsistent DisplayName is generated for a Collection used as the only parameter #684

Closed
@alisevych

Description

@alisevych

Description

Inconsistent DisplayName is generated for a Collection used as the only parameter.
For example: @DisplayName("setParam: and others")

To Reproduce

Steps to reproduce the behavior:

  1. Open IntelliJ Idea 2022.1.4 with one of the latest UTBotJava installed
  2. Add the following class - a Collection is the only input parameter of the method
import java.util.List;

public class CheckFinalSet  {

    private List<String> resource;

    public  void setParam( List<String> param) {
        this.resource = param;
    }

}
  1. Generate JUnit5 tests with "Not parametrized" option
  2. Check the generated test

Expected behavior

DisplayName should contain a consistent text about the parameters

Actual behavior

DisplayName contains the following text:
"setParam: and others"

Visual proofs (screenshots, logs, images)

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.DisplayName;

import java.util.TreeMap;

public class CheckFinalSetTest {
    ///region Test suites for executable CheckFinalSet.setParam

    ///region

    @Test
    @DisplayName("setParam:  and others")
    public void testSetParam() {
        CheckFinalSet checkFinalSet = new CheckFinalSet();
        TreeMap param = new TreeMap();

        checkFinalSet.setParam(param);
    }
    ///endregion

    ///endregion

}

Environment

Windows 10 Pro
IDEA 2022.1.4
JDK 8

Additional context

Same text in annotation is generated for with Set, List, Map - used as the only parameter.
If another parameter (String, int, etc.) the text contains the part before "and".
For instance:

@DisplayName("setParam: n > 0 and others")

Metadata

Metadata

Assignees

Labels

comp-summariesSomething related to the method names, code comments and display names generationctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions