我想知道如何为WSClient执行一些集成测试。我的项目是用maven构建的。
为了测试配置初始化和一些请求,我认为启动SoapUI Mock服务是个好主意。然后我进入了从一些帖子中检索到的配置。
在我的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>
我的MockService名为MyMock,应该在我的WSClient可以发送请求的http://127.0.0.1:8181/somepath上启动。但是我无法在mvn test
阶段开始模拟。
这是测试WSClients的适当方法吗?在这种情况下,问题或配置错误在哪里?
编辑:没有错误。我无法看到模拟侦听端口8181
。我看到的唯一消息(来自soapui.log)是:
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
比你提前和亲切的问候,
鲁
答案 0 :(得分:7)
根据http://www.soapui.org/Test-Automation/maven-2x.html,您需要运行mock
目标而不是test
目标。请更改您的goal
部分以致电mock
目标:
<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>
另外两项更改:
pre-integration-test
或process-test-classes
noBlock
添加true
选项。见上例。