This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "test" configuration profile for tests
Looks like test.application.properties was needed after all. :-) I replaced it with proper use of configuration profiles: http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-profiles
- Loading branch information
Showing
5 changed files
with
26 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# This configuration file is loaded additionally to applications.properties | ||
# during unit and integration tests. The options defined in this file override | ||
# the ones in application.properties. | ||
|
||
# Set this to true to test with the PDC result database turned on. | ||
# Note that this requires a locally running MongoDB instance. | ||
ddb.storage.enable=false | ||
|
||
# Test database settings. If you have enabled the database, make sure that | ||
# these are different from your development and production settings. | ||
spring.data.mongodb.host=127.0.0.1 | ||
spring.data.mongodb.port=27017 | ||
spring.data.mongodb.database=pdc | ||
spring.data.mongodb.collection=pdc_results_test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b208eac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice solution regarding the test configuration. So the profile is set via the command line argument and this code only runs in the test profile. And since the profile is called test, it will automatically use the properties under application-test.properties. Quite neat.
b208eac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The profile is actually not chosen as a command-line parameter in this case. Instead, the test classes which Use
Spring4JUnitRunner
have a@ActiveProfiles({"test"})
annotation attached to them.b208eac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see so you are switching the profile to test explicity here for those test classes?
b208eac
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, correct. This makes it impossible to run the tests "the wrong way" (by not specifying a profile explicitly).