hello! I'm looking into implementing some integrat...
# spring
d
hello! I'm looking into implementing some integration tests that require starting up the SpringBoot app, running some tests (through a plugin) and shutting down the app through Gradle. Maven has a built-in support for that (i.e.
start
and
stop
goals https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html). Based on https://github.com/spring-projects/spring-boot/issues/3982 and https://github.com/gradle/gradle/issues/1367 looks like there is no out of the box solution for that. Guess this could be done through the custom tasks that rely on Spring Actutator (as suggested here -> https://stackoverflow.com/questions/31407323/running-integration-tests-for-a-spring-boot-rest-service-using-gradle). Any suggestions?
f
Why does
@SpringBootTest
not work? Otherwise I would create a normal task with an
exec
call in
doLast
and use Bash to start it in the background, recording the PID and sending a
SIGTERM
to it once tests completed. Normal Unix stuff always gets the job done.
t
and maybe wrap everything in a docker container to ensure system dependencies are available. but yes, first loo at
@SpringBootTest
, usually it works well enough
f
Doing that would make it even simpler because you do not need to remember any PID. Just
docker-compose up -d
and
docker-compose kill
and you're golden.
You might get problems if you need to mount volumes and use something like CircleCI with remote docker daemons though.
d
simple
@SpringBootTest
won't work for me as I need to start up app from project_A and then run some task (custom plugin) from project_B
I'd rather avoid putting in the docker dependency if possible but guess might eventually do it as i might need it for another integration test setup as well
k
If your project_B is dockerized, than I would suggest looking into https://www.testcontainers.org/
d
trying to test out my libs/plugins with some example projects setup
i.e. example projects work fine as a reference but would love to also run some additional integration tests to ensure stuff works as expected
f
Docker is by far the best solution here because of OS differences.