Is the -D option only for sending system properties to Maven itself, or can
I set properties that my testcases can see when I run them via "maven test" ? In the Eclipse IDE, I can add "-Dmyproperty=foo" to the "VM Arguments" and my testcase can call System.getProperty() to get the value. I was trying to achieve the same thing with a Maven command line, like this but the System.getProperty() and even System.getProperties().list(System.out); show that it's not set when the testcase runs. maven test:single -Dtestcase=com.yadda.SystemPropertyTest -Dmyproperty=foo Am I using it wrong or was it even meant for this? -Jeff --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
You can allow your tests to see whatever properties you want by setting
the maven.junit.sysproperties property to the space-delimited list of property names. See http://maven.apache.org/reference/plugins/test/properties.html for more information. -----Original Message----- From: [hidden email] [mailto:[hidden email]] Sent: Thursday, June 09, 2005 3:43 PM To: [hidden email] Subject: Question about -D Is the -D option only for sending system properties to Maven itself, or can I set properties that my testcases can see when I run them via "maven test" ? In the Eclipse IDE, I can add "-Dmyproperty=foo" to the "VM Arguments" and my testcase can call System.getProperty() to get the value. I was trying to achieve the same thing with a Maven command line, like this but the System.getProperty() and even System.getProperties().list(System.out); show that it's not set when the testcase runs. maven test:single -Dtestcase=com.yadda.SystemPropertyTest -Dmyproperty=foo Am I using it wrong or was it even meant for this? -Jeff --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
Right. Your tests are getting spun off in a new VM, so Maven must
know what system properties it should pass along to the new VM. On 6/9/05, David Jackman <[hidden email]> wrote: > You can allow your tests to see whatever properties you want by setting > the maven.junit.sysproperties property to the space-delimited list of > property names. See > http://maven.apache.org/reference/plugins/test/properties.html for more > information. > > > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] > Sent: Thursday, June 09, 2005 3:43 PM > To: [hidden email] > Subject: Question about -D > > Is the -D option only for sending system properties to Maven itself, or > can I set properties that my testcases can see when I run them via > "maven test" > ? > > In the Eclipse IDE, I can add "-Dmyproperty=foo" to the "VM Arguments" > and my testcase can call System.getProperty() to get the value. > > I was trying to achieve the same thing with a Maven command line, like > this but the System.getProperty() and even > System.getProperties().list(System.out); show that it's not set when the > testcase runs. > > maven test:single -Dtestcase=com.yadda.SystemPropertyTest > -Dmyproperty=foo > > Am I using it wrong or was it even meant for this? > -Jeff > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > -- Jamie Bisotti Software Engineer Lexmark International, Inc. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
In reply to this post by J. Jeff Roberts
That does work, but I would cast a vote for a command-line way to pass system properties in - it would be much cleaner from the user's point of view. -Jeff |---------+------------------------------> | | "David Jackman" | | | <David.Jackman@fast| | | search.com> | | | | | | 06/09/2005 06:14 PM| | | Please respond to | | | "Maven Users List" | | | | |---------+------------------------------> >--------------------------------------------------------------------------------------------------------------------------------------------------| | | | To: "Maven Users List" <[hidden email]> | | cc: | | Subject: RE: Question about -D | >--------------------------------------------------------------------------------------------------------------------------------------------------| You can allow your tests to see whatever properties you want by setting the maven.junit.sysproperties property to the space-delimited list of property names. See http://maven.apache.org/reference/plugins/test/properties.html for more information. -----Original Message----- From: [hidden email] [mailto:[hidden email]] Sent: Thursday, June 09, 2005 3:43 PM To: [hidden email] Subject: Question about -D Is the -D option only for sending system properties to Maven itself, or can I set properties that my testcases can see when I run them via "maven test" ? In the Eclipse IDE, I can add "-Dmyproperty=foo" to the "VM Arguments" and my testcase can call System.getProperty() to get the value. I was trying to achieve the same thing with a Maven command line, like this but the System.getProperty() and even System.getProperties().list(System.out); show that it's not set when the testcase runs. maven test:single -Dtestcase=com.yadda.SystemPropertyTest -Dmyproperty=foo Am I using it wrong or was it even meant for this? -Jeff --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
You should probably log an enhancement request in JIRA.
On 6/10/05, [hidden email] <[hidden email]> wrote: > > That does work, but I would cast a vote for a command-line way to pass > system properties in - it would be much cleaner from the user's point of > view. > > -Jeff > > > > |---------+------------------------------> > | | "David Jackman" | > | | <David.Jackman@fast| > | | search.com> | > | | | > | | 06/09/2005 06:14 PM| > | | Please respond to | > | | "Maven Users List" | > | | | > |---------+------------------------------> > >--------------------------------------------------------------------------------------------------------------------------------------------------| > | | > | To: "Maven Users List" <[hidden email]> | > | cc: | > | Subject: RE: Question about -D | > >--------------------------------------------------------------------------------------------------------------------------------------------------| > > > > > You can allow your tests to see whatever properties you want by setting > the maven.junit.sysproperties property to the space-delimited list of > property names. See > http://maven.apache.org/reference/plugins/test/properties.html for more > information. > > > -----Original Message----- > From: [hidden email] [mailto:[hidden email]] > Sent: Thursday, June 09, 2005 3:43 PM > To: [hidden email] > Subject: Question about -D > > Is the -D option only for sending system properties to Maven itself, or > can I set properties that my testcases can see when I run them via > "maven test" > ? > > In the Eclipse IDE, I can add "-Dmyproperty=foo" to the "VM Arguments" > and my testcase can call System.getProperty() to get the value. > > I was trying to achieve the same thing with a Maven command line, like > this but the System.getProperty() and even > System.getProperties().list(System.out); show that it's not set when the > testcase runs. > > maven test:single -Dtestcase=com.yadda.SystemPropertyTest > -Dmyproperty=foo > > Am I using it wrong or was it even meant for this? > -Jeff > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [hidden email] > For additional commands, e-mail: [hidden email] > > -- Jamie Bisotti Software Engineer Lexmark International, Inc. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
In reply to this post by J. Jeff Roberts
You can still do this on the command line. It would look something like
this (all on one line): maven test:single -Dtestcase=com.yadda.SystemPropertyTest -Dmyproperty=foo -Dmaven.junit.sysproperties=myproperty It's a bit trickier if there's more than one property, because the maven.junit.sysproperties value is space-delimited: maven test:single -Dtestcase=com.yadda.SystemPropertyTest -Dmyproperty=foo -Dother=bar "-Dmaven.junit.sysproperties=myproperty other" It would be harder to do much different because the -D parameter is not a Maven parameter, but a Java parameter. -----Original Message----- From: [hidden email] [mailto:[hidden email]] Sent: Friday, June 10, 2005 8:17 AM To: Maven Users List Subject: RE: Question about -D That does work, but I would cast a vote for a command-line way to pass system properties in - it would be much cleaner from the user's point of view. -Jeff |---------+------------------------------> | | "David Jackman" | | | <David.Jackman@fast| | | search.com> | | | | | | 06/09/2005 06:14 PM| | | Please respond to | | | "Maven Users List" | | | | |---------+------------------------------> >----------------------------------------------------------------------- ------------------------------------------------------------------------ ---| | | | To: "Maven Users List" <[hidden email]> | | cc: | | Subject: RE: Question about -D | >----------------------------------------------------------------------- ------------------------------------------------------------------------ ---| You can allow your tests to see whatever properties you want by setting the maven.junit.sysproperties property to the space-delimited list of property names. See http://maven.apache.org/reference/plugins/test/properties.html for more information. -----Original Message----- From: [hidden email] [mailto:[hidden email]] Sent: Thursday, June 09, 2005 3:43 PM To: [hidden email] Subject: Question about -D Is the -D option only for sending system properties to Maven itself, or can I set properties that my testcases can see when I run them via "maven test" ? In the Eclipse IDE, I can add "-Dmyproperty=foo" to the "VM Arguments" and my testcase can call System.getProperty() to get the value. I was trying to achieve the same thing with a Maven command line, like this but the System.getProperty() and even System.getProperties().list(System.out); show that it's not set when the testcase runs. maven test:single -Dtestcase=com.yadda.SystemPropertyTest -Dmyproperty=foo Am I using it wrong or was it even meant for this? -Jeff --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
On 6/10/05, David Jackman <[hidden email]> wrote:
> You can still do this on the command line. It would look something like > this (all on one line): > maven test:single > -Dtestcase=com.yadda.SystemPropertyTest > -Dmyproperty=foo > -Dmaven.junit.sysproperties=myproperty > > It's a bit trickier if there's more than one property, because the > maven.junit.sysproperties value is space-delimited: > maven test:single > -Dtestcase=com.yadda.SystemPropertyTest > -Dmyproperty=foo > -Dother=bar > "-Dmaven.junit.sysproperties=myproperty other" > > It would be harder to do much different because the -D parameter is not > a Maven parameter, but a Java parameter. > I disagree. Maven could be made so that it passed any "non-standard" system property on as a system property to new VMs that it spins off. Couldn't it? -- Jamie Bisotti --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
Free forum by Nabble | Edit this page |