gpt4 book ai didi

java - Maven 测试中集成的 SoapUI Mock

转载 作者:塔克拉玛干 更新时间:2023-11-03 04:23:38 25 4
gpt4 key购买 nike

我想知道如何为 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>

我的名为 MyMock 的 MockService 应该已在 http://127.0.0.1:8181/somepath 上启动我的 WSClient 可以在哪里发送请求。但是我无法在 mvn test 阶段启动模拟。

这是测试 WSClient 的合适方法吗?在那种情况下,问题或配置错误在哪里?

编辑:没有错误。我看不到那个端口 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

在此先向您致以亲切的问候,

鲁本

最佳答案

根据 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-testprocess-test-classes
  • noBlock选项添加为true

例子见上。

关于java - Maven 测试中集成的 SoapUI Mock,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9792146/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com