jeudi 16 mai 2019

Cannot find spring application class in unit test class

We are in the process of creating from the scratch product with spring webflux. We are writing our unit test cases. Though I can able to get the Spring Application main class in my import, when we run mvn clean install, it is keep on telling that Compilation failure, cannot find class. How we can overcome this?

enter code here

My project structure is,

Application
     -app-web-module
        -src/java/com/org/SpringApplicationClass
        -pom.xml
     -app-web-unitcases
        -src/test/com/org/mytestclass
        -pom.xml

And my test class is,

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWebTestClient
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@ContextConfiguration(classes = com.org.MainApplication.class)
public class BaseACTest {


    @Autowired
    private WebTestClient webTestClient;

    @BeforeAll
    public void init1() {
        MockitoAnnotations.initMocks(this);
    }

    @BeforeEach
    public void init() {
        Assertions.assertNotNull(webTestClient);
    }

    @Test
    public void testGetAllAmenities() {
        webTestClient.get().uri("/urltobeplaced/1234")
            .header("X-Request-ID", "123")
            .header("X-Session-ID", "123")
            .header("X-Application-ID", "123")
            .exchange()
            .expectStatus().isOk();
    }

}```

Aucun commentaire:

Enregistrer un commentaire