unit-testinggradlemicronaut

Is it possible to stop the embedded server from starting when running the unit tests?


I'm running the gradle test task on a Micronaut project and the embedded server is getting started.

In local that is not much of an issue, but when running the unit tests in the CI environment there isn't a database available for the server to connect to. So ideally we would run the gradle test task without starting the server.

Is it possible to configure Micronaut to not do that?


Solution

  • Is it possible to configure Micronaut to not do that?

    Yes. The embedded server is not started by default. It is only started if you write code in your test to start it or if you mark the test with @MicronautTest. If you don't do either of those things, the server shouldn't start.