Skip to content

Many identical imports when generating tests into other module #1286

Closed
@alisevych

Description

@alisevych

Description

Many identical imports when generating tests into other module

To Reproduce

  1. Install one of the latest UnitTestBot plugin build from main, for example in IntelliJ Idea 2022.2.3 (latest)
  2. Open UTBotJava project
  3. Open test generation dialog for
  • org.utbot.examples.exceptions.ExceptionExamples
  • org.utbot.examples.arrays.ArrayOfObjects
  1. Select some other Test sources root and click Generate Tests

Expected behavior

Generated test class should not contain identical imports.
Also : these imports of classes from other modules are not resolved. How should we keep them?

Actual behavior

Generated test class contains many identical imports.

Visual proofs (screenshots, logs, images)

import org.utbot.examples.exceptions.ExceptionExamples;
import org.utbot.examples.exceptions.ExceptionExamples;
import org.utbot.examples.exceptions.ExceptionExamples;

...
import org.utbot.api.mock.UtMock;
import org.utbot.api.mock.UtMock;
import org.utbot.examples.arrays.ArrayOfObjects;
import org.utbot.examples.arrays.ArrayOfObjects;
import org.utbot.examples.arrays.ArrayOfObjects;
...
import org.utbot.examples.arrays.ObjectWithPrimitivesClass;
import org.utbot.examples.arrays.ObjectWithPrimitivesClass;
...

Environment

Windows 10 Pro
IntelliJ IDEA 2022.2.3

Additional context

Verified reproducing on two version of main:

Metadata

Metadata

Labels

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

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions