Forum Discussion

SKoneru's avatar
SKoneru
Contributor
11 years ago

[Resolved] Switch to different environments via maven

HI,

I have a maven pom.xml which is working fine. But now I enhanced my project to run in different environments and tests work great in the SOAPUI-PRO tool.
But now I want to configure maven to run in different environment profiles. How can I do that?

I didn't find any such plugin settings defined in Maven tutorial(http://www.soapui.org/Test-Automation/maven-2x.html).
But for testRunner there is an "E" option.

Please provide any suggestions how to configure in Maven.

Thanks
Surya

3 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi,

    There is a setting for environment but it was missing from the documentation, sorry about that. I have added it to the page under "5.1. eviware:soapui:test settings".

    Regards,
    Anders
    SmartBear Sweden
  • I did try providing <environment> option and it didn't work. The value that I provided does not override with what is saved with the project.

    In maven pom.xml file, I defined the environment in configuration section as follows-
    <plugin>
    <groupId>eviware</groupId>
    <artifactId>maven-soapui-pro-plugin</artifactId>
    <version>4.5.1</version>
    <executions>
    <execution>
    <phase>test</phase>
    <goals>
    <goal>test</goal>
    </goals>
    <configuration>
    <projectFile>Trading-soapui-project.xml</projectFile>
    <junitReport>true</junitReport>
    <exportAll>true</exportAll>
    <outputFolder>${outputdir}</outputFolder>
    <settingsFile>../Common/soapui-settings.xml</settingsFile>
    <environment>QA</environment>
    </configuration>
    </execution>
    </executions>

    In the test case there is a Groovy test step that just prints the environment. Below is the simple Groovy script:-
    def env = testRunner.testCase.testSuite.project.getActiveEnvironment().getName()
    log.info "environment= ${env}"

    This always prints the environment value with what is saved in the project. The value that we provided does not override. I saved the project with environment as "Production", so the
    value displays as "Production" rather than "QA".

    Can you please validate if this functionality is working.

    Thanks in advance.