Skip to content

Nested classes are duplicated in generated testclass #779

Closed
@volivan239

Description

@volivan239

Description

Currently, codegen produces incorrect testclasses when there are nested classes in src code.

To Reproduce

Consider example:

public class OtherClass {
    public class InnerClass {
        private int y;
        InnerClass(int y) {
            this.y = y;
        }
        public class DeepInner {
            public int f() {
                if (y == 1) return 1;
                return 2;
            }
            public int f2() {
                return 0;
            }
        }
        public int g() {
            return 3;
        }
    }
    public int h() {
        return 4;
    }
}
  1. Run tests for all methods from class OtherClass (currently you can do it in this branch)
  2. Run tests for class DeepInner only.

Expected behavior

Correct tests are generated.

Actual behavior

  1. class InnerClassTest is duplicated
  2. main class is called OtherClass_InnerClass_DeepInnerTest, which does not correlate to file name DeepInnerTest.java, which causes compilation error.

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions