Skip to content

Selecting one method launches tests for all methods with same signature from nested classes #1407

Closed
@volivan239

Description

@volivan239

To Reproduce

Launch the action on the following class, select only method f and click Generate:

class ExampleClass {
    int f() {
        return 1;
    }
    static class Inner {
        int f() {
            return 1;
        }
    }
}

Expected behavior

Only tests for ExampleClass.f are generated.

Actual behavior

Tests are generated for both ExampleClass.f and ExampleClass.Inner.f

Visual proofs (screenshots, logs, images)

public final class ExampleClassTest {
    ///region Test suites for executable rndpkg.ExampleClass.f

    ///region

    @Test
    public void testF2() {
        ExampleClass exampleClass = new ExampleClass();

        int actual = exampleClass.f();

        assertEquals(1, actual);
    }
    ///endregion

    ///endregion

    ///region Tests for Inner

    @Nested
    public final class InnerTest {
        ///region Test suites for executable rndpkg.ExampleClass$Inner.f

        ///region

        @Test
        public void testF1() {
            Inner inner = new Inner();

            int actual = inner.f();

            assertEquals(1, actual);
        }
        ///endregion

        ///endregion
    }
    ///endregion
}

Additional context

Seems like the problem is in org.utbot.intellij.plugin.process.EngineProcess#findMethodsInClassMatchingSelected, more specific, in that Signatures doesn't contain info about declaring class.

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions