Forum Discussion

mchelikani's avatar
mchelikani
Contributor
12 years ago

[Resolved] How do I access maven or command line arguments

Hello,
I need to access the maven argument or command line argument in one of the event handlers ( Ex: <host> or -h).

Thanks for the help.

-Madhu.

6 Replies

  • redfish4ktc2's avatar
    redfish4ktc2
    Super Contributor
    hi,
    arguments are used to set properties of the underlying runner, so in you event handler, you can retrieve the arguments by getting values from the testRunner instance
  • Thanks for the Reply.

    I need to get maven arguments/ command line arguments in ProjectRunner.beforeRun Event Handler.

    Can I get an example How I can retrieve them?
  • One way of getting the command line arguments is by looking at the result of System.getProperty("sun.java.command"). That should give you the full command line as a String that could be splitted/parsed.

    Regards
    Joel Jonsson
    SmartBear Sweden
  • Joel Thanks for Reply!

    My appologies for not asking the question correctly.

    I would like to access the configurations that are set in pom file for soapui project for integrating soapui with maven. The place i would like to access them is in ProjectRunListener.beforeRun.

    I am here pasting the pom file where I highlighted the items in bold.
    <build>
    <plugins>
    <plugin>
    <groupId>eviware</groupId>
    <artifactId>maven-soapui-pro-plugin</artifactId>
    <version>4.5.1</version>
    <!-- <dependencies>
    <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>5.1.6</version>
    </dependency>
    </dependencies> -->
    <executions>
    <execution>
    <phase>test</phase>
    <goals>
    <goal>test</goal>
    </goals>
    <configuration>
    <projectFile>b2b/src/test/soap-ui/IHG-B2B-soapui-project.xml</projectFile>
    <!--<endpoint>http://qa.b2b.ihg.com</endpoint>-->
    <host>utc.b2b.ihg.com</host>
    <!--<environment>qa</environment>-->
    <!--<testSuite>ResDirect</testSuite>
    <testCase>HeartBeatTestWithToken</testCase>-->
    <outputFolder>target/soap-ui/</outputFolder>
    <junitReport>true</junitReport>
    <printReport>true</printReport>
    <exportAll>true</exportAll>
    <reportName>Project Report</reportName>
    <reportFormat>PDF,HTML</reportFormat>
    <globalProperties>
    <value>environment=utc</value>
    <value>resultsPath=target/soap-ui/Results/</value>
    <value>resultsComparePath=target/soap-ui/ResultsComparePath/</value>
    <value>testcase_src=${project.basedir}/b2b/src/test/soap-ui/</value>

    </globalProperties>
    <soapuiProperties>
    <property>
    <name>soapui.home</name>
    <value>${env.SOAPUI_HOME}/bin</value>
    </property>
    </soapuiProperties>
    </configuration>
    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

    Thanks and appreciate for the response.
  • Actually I think redfish4ktcd got the runners mixed up in his reply. You need to get the command line runner and then read the properties "host" and "outputFolder" on it, like so:

    def def runner = com.eviware.soapui.SoapUI.cmdLineRunner
    def myHost = runner.host
    def myOutputFolder = runner.outputFolder

    Hope this helps,
    Manne