4

I'm trying to do the following, but in IntelliJ with a TestNG run configuration:

mvn clean install -Dfoo=bar

So, the value for the foo system property should be bar:

System.out.println(System.getProperty("foo")); ====== bar 

All potential answers I've googled either tell me to hardcode variables into my pom.xml (which I can't do) or say to "just set it in Edit Configurations..." without showing what a properly set variable looks like. I dug through the IntelliJ manual too.

I tried all the logical names for "foo" in both Run/Debug Configurations/Parameters tab and Run/Debug Configurations/Environment Variables, such as Dfoo and -Dfoo.

Run/Debug Configurations and Environment Variables

1 Answer 1

7

Use a Maven configuration instead of a TestNG configuration. You can still run your TestNG tests from the Maven configuration:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, using a Maven configuration solved the problem. I was using a TestNG configuration. I edited your answer a little bit to provide more context for someone finding this page on Google.
Maybe you would also like Maven Helper plugin

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.