Sai Krishna
Sai Krishna

Reputation: 691

Compilation Errors with @SpringBootTest test configuration

I have two child modules within a parent maven project, each child module with its own pom -> lets call them Modules api-application-module and api-int-tests-module. api-application-module has all the application code and api-int-tests-module has the integration tests that are run in a different docker container, hitting the docker container on which the application module runs. The structure is as follows

api-application-module
  -> src/main/java/com/cmp/application
      -> ServerApplication.java (This is the main class)
  -> src/test/java/com/cmp/application 
      -> .... unit tests



api-int-tests-module
   -> src/test/java/com/cmp/application(this is the same test package as application-module)
         ->ApiIntTests.java


Here, ApiIntTests.java contains all the integration tests. In the integration tests, I want to override some of the config values which the api-application-module uses, only for the sake of tests. Im trying to do it as follows

@SpringBootTest(classes = ServerApplication.class)
@TestPropertySource(
    properties = {
      "externalApi.baseUrl=http://wiremock-svc.api.svc.cluster.local:90"
    })
public class ApiIntTests {
    .......
    .......
}

When I run the mvn clean deploy or mvn clean install commands, I get a compilation error as follows

Compilation failure
[ERROR] api-application/api-integration-tests/src/test/java/com/cmp/application/ApiIntTests.java:[36,27] cannot find symbol
[ERROR]   symbol: class ServerApplication

I've tried multiple things -> Adding api-application-module as a dependency in the pom of api-integration-test-module. Ensured the path and class name values are correct. I still am getting the same compilation error. Can someone help me with fixing this.

Upvotes: 0

Views: 48

Answers (0)

Related Questions