Skip to content

Generated JUnit5 test contains unused imports #1292

Open
@arnosthavelka

Description

@arnosthavelka

I can see unused imports when I open generated test in my IDE:

import org.junit.jupiter.api.extension.ExtendWith;
import static org.springframework.cloud.contract.verifier.util.ContractVerifierUtil.*;

Sample
My integration to contracts is like that:

<plugin>
	<groupId>org.springframework.cloud</groupId>
	<artifactId>spring-cloud-contract-maven-plugin</artifactId>
	<version>${spring-cloud.version}</version>
	<extensions>true</extensions>
	<configuration>
		<baseClassForTests>com.github.aha.poc.junit.springboot.AbstractContractTest</baseClassForTests> 
		<testFramework>JUNIT5</testFramework> 
	</configuration>
</plugin>

The test base class is defined as:

@SpringBootTest(webEnvironment = MOCK)
public class AbstractContractTest {

	@Autowired
	private WebApplicationContext context;

	@BeforeEach
	void setup() {
		webAppContextSetup(context);
	}
}

The complete example can be found here: https://github.com/arnosthavelka/junit-poc/tree/develop/spring-boot/src/test/resources/contracts/city.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions