Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SoapUI Mock integrated in Maven test

I was wondering how to perform some integration tests for a WSClient. My project is built with maven.

In order to test the configuration initialization and some requests I thought it was a good idea to start a SoapUI Mock service. Then I got into that configuration retrieved from some posts.

In my pom.xml

    <plugin>
            <groupId>eviware</groupId>
            <artifactId>maven-soapui-plugin</artifactId>
            <version>4.0.1</version>
            <executions>
                <execution>
                    <id>StartupMock</id>
                    <configuration>
                        <projectFile>src/test/soapui/MyMock-soapui-project.xml</projectFile>
                        <outputFolder>${project.build.directory}/surefire-reports</outputFolder>
                        <junitReport>true</junitReport>
                        <host>http://127.0.0.1:8181</host>
                        <mockService>DataProviderMock</mockService>
                    </configuration>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <phase>test</phase>
                </execution>
            </executions>
        </plugin>

My MockService called MyMock should have been started on http://127.0.0.1:8181/somepath where my WSClient could send the requests. But I wasn't able to start the mock during the mvn test phase.

Is that the apropriate way to test WSClients? In that case, where is the problem or the misconfiguration?

EDIT: There is no error. I can't see the mock listening on that port 8181. The only messages I see (from soapui.log) are:

2012-03-21 10:17:21,011 WARN  [SoapUI] Missing folder [D:\proyectos\everest-utils\everest-bridge\trunk\.\ext] for external libraries
2012-03-21 10:17:21,392 INFO  [DefaultSoapUICore] initialized soapui-settings from [C:\Users\rromero\soapui-settings.xml]
2012-03-21 10:17:23,205 INFO  [WsdlProject] Loaded project from [file:/D:/proyectos/everest-utils/everest-bridge/trunk/src/test/soapui/MyMock-soapui-project.xml]
2012-03-21 10:17:23,891 INFO  [SoapUITestCaseRunner] Running soapUI tests in project [DataProvider]
2012-03-21 10:17:23,894 INFO  [SoapUITestCaseRunner] Running Project [MyMock], runType = SEQUENTIAL
2012-03-21 10:17:23,900 INFO  [SoapUITestCaseRunner] Project [MyMock] finished with status [FINISHED] in 0ms

Than you in advance and kind regards,

Ruben

like image 525
Ruben Romero Avatar asked Mar 20 '12 17:03

Ruben Romero


People also ask

Can maven be used for testing?

Maven is the latest build testing tool. It has several new features as compare to Ant, like dependency, etc. Maven is a project build or project management tool. It is used to check the compilation issues between framework components whenever multiple test engineer integrates their files into the same framework.


1 Answers

According to http://www.soapui.org/Test-Automation/maven-2x.html you need to run the mock goal instead of the test goal. Please change your goal section to call the mock goal:

    <plugin>
        <groupId>eviware</groupId>
        <artifactId>maven-soapui-plugin</artifactId>
        <version>4.6.1</version>
        <executions>
            <execution>
                <id>StartupMock</id>
                <configuration>
                    <projectFile>src/test/soapui/MyMock-soapui-project.xml</projectFile>
                    <outputFolder>${project.build.directory}/surefire-reports</outputFolder>
                    <junitReport>true</junitReport>
                    <host>http://127.0.0.1:8181</host>
                    <mockService>DataProviderMock</mockService>
                    <noBlock>true</noBlock>
                </configuration>
                <goals>
                    <goal>mock</goal>
                </goals>
                <phase>process-test-classes</phase>
            </execution>
        </executions>
    </plugin>

Two more changes:

  • Make sure you start the mock test in a phase previous to running the tests, e.g. in pre-integration-test or process-test-classes
  • Add the noBlockoption with true.

See above for example.

like image 140
nwinkler Avatar answered Sep 21 '22 12:09

nwinkler