Skip to content

Add a flag to disable imports addition from formatter side #1410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 22, 2022

Conversation

sofurihafe
Copy link
Member

Description

Choosing a different package as a test source root may lead to unnecessary repeating imports being rendered. The cause was that formatter was able to add extra imports when there was a method (which is from a different package) invocation. This PR fixes prohibits such behavior.

Fixes # (1286)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Automated Testing

utbot-samples.

Manual Scenario

Open UTBotJava project, generate tests for the org.utbot.examples.exceptions.ExceptionExamples class choosing different package as a test source root location. Verify that the generated code has no repeating imports as it was described in the issue:

package org.utbot.examples.exceptions;

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

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.utbot.runtime.utils.java.UtUtils.createInstance;

public final class ExceptionExamplesTest {
    <...>
}

@sofurihafe sofurihafe linked an issue Nov 22, 2022 that may be closed by this pull request
@EgorkaKulikov EgorkaKulikov enabled auto-merge (squash) November 22, 2022 13:03
@EgorkaKulikov EgorkaKulikov merged commit 95d6cb0 into main Nov 22, 2022
@EgorkaKulikov EgorkaKulikov deleted the andrey-t/repeating-imports branch November 22, 2022 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Many identical imports when generating tests into other module
2 participants