I have a simple RestAPI which runs on my local and an AWS ECS cloud. I want to run unit tests and integration tests before deploying my app to the cloud. How can I do this with Maven profiles efficiently?
I want to define Maven profiles such as unit-test and integration-test. I want to run these tests using these commands :
mvn clean test -P unit-test
mvn install -P integration-test
Also I have a dev database and production database. When doing integration tests, the app must connect to a seperate test database which creates a need for 2 databases(for dev and prod environments). How can I manage this using Maven profiles?
And I want to define Maven profiles, dev and prod and create application-dev.properties and application-prod.properties so my application knows which configuration to take into account. But I also need a test database for testing, so do I need to create seperate profiles and application.properties files for these tests? (because I need to specify the test database in this application.properties file)
In the end, It seems to me that I need to create a lot of Maven profiles(dev, dev-unit-test,dev-integration-test,prod,prod-unit-test,prod-integration-test).
I got confused and I think there must a better way for managing unit and integration tests accross different environments.
Also, another question : How can I make my application discriminate between unit tests and integration tests regarding to integration-test profile?
EDIT : I figured out how to run unit and integration tests seperately and make my integration and unit tests discriminate the classes(refer to @Liquidpie's answer her How do I get my Maven Integration tests to run). But I still need a good way to define seperate profiles for dev and prod environments as they need to access a test database. How can I achieve that?