1

I want to run UAT tests using Spring Boot. I want to run them on multiple configurations in parallel.

I will start by saying that I'm not sure if it's a good practice to run mvn test on the same project in parallel. But let's pretend I'll do that.

The suggestions I find on the internet for testing different configurations are:

Both will not work with running in parallel: application.yml can't have different values at the same time, the same with environment variables.

Is there any kind of way to specify the profile with command line arguments, something like mvn test -DprofilesActive=profilex ? Or any other way?

EDIT - concrete example:

I have a REST service deployed on 2 servers.

I have a separate project for testing the REST service using Cucumber (so JUnit tests). This is a Spring Boot project. It takes the URL of the server where the REST service is deployed from application.yml (at the moment).

I want to run this test project in parallel twice , for each deployed REST service, meaning with the 1st URL and the 2nd URL.

I run it using mvn test.

Anakin001
  • 1,226
  • 2
  • 14
  • 30
  • 1
    try this `mvn spring-boot:run -Drun.arguments="--spring.profiles.active=test,--spring.profiles.active=dev"` – rdj7 Nov 22 '18 at 14:45
  • What is it that you're actually trying to do? Because it sounds like you just want to use different properties by test, override them in the tests using @TestPropertySource(locations="classpath:override.properties") – Heuriskos Nov 22 '18 at 15:13
  • I want to run the tests in parallel with multiple configurations. Something like TestPropertySource will only give me a file with 1 value per property, I need several values for the same property being used at the same time in tests running in parallel. – Anakin001 Nov 22 '18 at 15:18
  • What are your mvn tests? I think you need to post some code, as it's difficult to understand what you're trying to do. See also the XY problem https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem – Heuriskos Nov 22 '18 at 15:27
  • You are right about the XY problem :) I edited my question. – Anakin001 Nov 22 '18 at 15:34
  • 1
    `Is there any kind of way to specify the profile with command line arguments, something like mvn test -DprofilesActive=profilex ?` yes, you can. See https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-profiles.html (you will need to pass the environmental variable to mvn). Then to run the UAT tests at the same time, you just need to set off the mvn command twice, with different command line parameters. – Heuriskos Nov 22 '18 at 16:03
  • I didn't know that Spring Boot uses the environment variables even during testing - I only used them for running applications in the past. I will try to test this later today. – Anakin001 Nov 23 '18 at 10:13
  • I tested, indeed it works. If you post this answer I will mark it as correct. Thanks. – Anakin001 Nov 23 '18 at 12:24

0 Answers0