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

Community
  • 1
  • 1
JaneGoodall
  • 1,478
  • 2
  • 15
  • 22

1 Answers1

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

JaneGoodall
  • 1,478
  • 2
  • 15
  • 22
Meo
  • 12,020
  • 7
  • 45
  • 52
  • 1
    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. – JaneGoodall Jun 08 '15 at 22:38
  • Maybe you would also like [Maven Helper plugin](https://plugins.jetbrains.com/plugin/7179) – Meo Jun 08 '15 at 22:45