I have a maven pom with profiles. In one of those profiles I refer to a system variable like this
<profile>
<id>kasper</id>
<properties>
<user>${username}</user>
</properties>
</profile>
When I invoke maven command line with the -Dusername=kasper all seems to be well.
The thing is, I import this project in IntelliJ. IntelliJ 13 allows to select profiles with which to run, through the Maven Tool Window.
When I select this specific profile to use while running tests, I can't seem to find how to replace this property correctly, i.e. to really tell IntelliJ that it has to pick this or that user name to run my maven tests, I tried a bit of everything and it doesn't seem to pick ot up.
Anybody an idea?
Kasper
In IntelliJ 14 maven profiles are not passed to tests (by default).
You can activate this mechanism via an option in Settings -> Maven -> Running Tests which let you enable passing of systemPropertyVariables to unit tests - this should cover your case.
View -> Tool Windows -> Maven Projects then right clicking on needed phase, e.g. package it will be second item in context menu called *Create [project_name] package ...*
And on some tabs you could override VM properties, add profiles, etc.
OK, I got it.
Go to the Intellij configuration on JUnit or TestNG (whichever one you are using). Under VMoptions... you can add the custom system property variables from Maven to debugger beside -ea option just like terminal command.
-ea -Dtest.environment=QA
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