I have declared some properties that are specific to Maven profiles. A part of my pom.xml:
<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<my.properties.file>foo.xml</my.properties.file>
</properties>
</profile>
<profile>
<id>ci</id>
<properties>
<my.properties.file>bar.xml</my.properties.file>
</properties>
</profile>
</profiles>
I encounter some problem to use the "ci" Maven profile when I start Junit tests via IntelliJ IDEA 2016.
I activate my profile via the "Maven Projects" panel, then I start tests. The problem is the "my.properties.file" property value is equal to "foo.xml", not "bar.xml".
I have no problem with command-line (I can use the "-Pci" flag). How can I tell IntelliJ to use the "ci" profile? Thx.
Run testsOpen the Maven tool window. Under the Lifecycle node select test. Note that goals specified in the Maven surefire plugin will be activated at this phase and all tests in a project or in a module will be run.
The Maven Surefire Plugin 2.22. 0 (or newer) provides native support for JUnit 5. If we want to use the native JUnit 5 support of the Maven Surefire Plugin, we must ensure that at least one test engine implementation is found from the classpath. We can run our unit tests by using the command: mvn clean test.
You should add the profiles to the Maven setting.xml file (you should find it in the path ${YOUR_MAVEN_HOME}\apache-maven-3.1.1\conf\setting.xml). Then, you have to open intellij, click on View > Tool Windows > Maven Projects. There, you should see your profiles (ci and release) and select the correct one.
Hope this can help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With