Maven SoapUI 插件 - 如何在 Maven 的生命周期中执行 2 个 SoapUI 测试项目

Posted

技术标签:

【中文标题】Maven SoapUI 插件 - 如何在 Maven 的生命周期中执行 2 个 SoapUI 测试项目【英文标题】:Maven SoapUI plugin - how to execute 2 SoapUI test projects during Maven's lifecycle 【发布时间】:2012-04-12 01:13:24 【问题描述】:

我有 2 个不同的 SoapUI 测试项目,我想在构建期间运行(我为此使用 maven-soapui-plugin 3.6.1 和 Maven 3)。 目前我所能做的就是只执行 1 个项目(请参阅我的 pom.xml 文件)......假设我想执行 2 个 SoapUI 测试项目并控制它们的执行顺序...... 这样做的正确语法是什么?

我当前的 pom.xml 文件:

 <plugin>                                                                                                                      
     <groupId>eviware</groupId>                                                                                                
     <artifactId>maven-soapui-plugin</artifactId>                                                                              
     <version>3.6.1</version>                                                                                                  
     <configuration>                                                                                                           
      <projectFile>$project.basedir\src\test\resources\soapui\Web-Service-automatic-testing-soapui-project.xml</projectFile> 
         <outputFolder>$project.basedir\src\test\resources\soapui\output</outputFolder>                                      
         <junitReport>true</junitReport>                                                                                       
     </configuration>                                                                                                          
     <executions>                                                                                                              
         <execution>                                                                                                           
             <id>soapUI</id>                                                                                                   
             <!--Run as part of the test phase in the Maven lifecycle-->                                                       
             <phase>test</phase>                                                                                               
             <goals>                                                                                                           
                 <goal>test</goal>                                                                                             
             </goals>                                                                                                          
         </execution>                                                                                                          
     </executions>                                                                                                             
 </plugin>

【问题讨论】:

不久前我也经历过同样的事情,我的问题和解决方案可以在这里找到。一个重要的说明,我正在处理 300 + 服务。 ***.com/questions/9184862/… 【参考方案1】:

您可以为 SoapUI 插件指定多个执行。例如:

 <plugin>                                                                                                                      
     <groupId>eviware</groupId>                                                                                                
     <artifactId>maven-soapui-plugin</artifactId>                                                                              
     <version>3.6.1</version>                                                                                                  
     <configuration>                                      
         <outputFolder>$project.basedir\src\test\resources\soapui\output</outputFolder>
         <junitReport>true</junitReport>
     </configuration>
     <executions>
         <execution>
             <id>soapUI1</id>
             <phase>test</phase>
             <goals>
                 <goal>test</goal>
             </goals>
            <configuration>
              <projectFile>$project.basedir\src\test\resources\soapui\Web-Service-automatic-testing-soapui-project1.xml</projectFile> 
            </configuration>
         </execution>                                                                                                          
         <execution>
             <id>soapUI2</id>
             <phase>test</phase>
             <goals>
                 <goal>test</goal>
             </goals>
            <configuration>
              <projectFile>$project.basedir\src\test\resources\soapui\Web-Service-automatic-testing-soapui-project2.xml</projectFile> 
            </configuration>
         </execution>                                                                                                          
     </executions>                                                                                                             
 </plugin>

【讨论】:

谢谢你-我会试试的。它们将按什么顺序执行? 按照您声明它们的顺序。还要确保它们具有唯一的执行 ID。 谢谢。我已经提交了更改,明天早上(在夜间构建之后)我会看看它是如何工作的。 我正在为我的项目尝试相同的方法,但它不起作用。我检查了这个插件的所有版本。 如果你想指定一个特定的testSuite怎么办?我放了 blabla ////> 但似乎相同的测试用例被多次执行并且乱序。【参考方案2】:

您可以使用this 插件来满足上述要求。下面给出了它的代码块。

<build>
        <plugins>
            <plugin>
                <groupId>com.github.redfish4ktc.soapui</groupId>
                <artifactId>maven-soapui-extension-plugin</artifactId>
                <version>4.6.4.1</version>
                <executions>
                    <execution>
                        <id>soapUI1</id>
                        <phase>test</phase>
                        <goals>
                            <goal>test-multi</goal>
                        </goals>
                        <configuration>
                            <projectFiles>
                                <scan>
                                    <baseDirectory>/home/waruna/workspace/soapuitest/src/main/resources/projects</baseDirectory>
                                    <includes>
                                        <include>*.xml</include>
                                    </includes>
                                    <excludes>
                                        <exclude>**/*fail-*-soapui-project.xml</exclude>
                                        <exclude>**/composite-projects/**</exclude>
                                    </excludes>
                                </scan>
                            </projectFiles>
                            <outputFolder>/home/waruna/workspace/soapuitest/src/main/resources/</outputFolder>
                            <junitReport>true</junitReport>
                            <useOutputFolderPerProject>true</useOutputFolderPerProject>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

【讨论】:

【参考方案3】:

不要走行家路线。使用命令行 testrunner.sh 并在 for 循环中运行所有测试。

【讨论】:

【参考方案4】:

从junit test运行soapui复合项目

从 junit 测试运行 SOAPUI 项目的唯一主要问题是找到所有正确的 SOAPUI 依赖 jar。

我创建了一个包含所有必需 jar 的 uber jar。这个新 jar 在下面添加到 lib 文件夹中的 GitHub 代码库中。这个 uber jar 兼容 Ready API 1.5.0 版本。 (请注意,我已经尝试过使用复合项目进行 rest API 测试)

Junit 测试用例采用复合项目路径并运行每个测试用例的所有测试步骤。

在步骤级别运行测试有助于在构建失败时进行调试。

http://www.learnteachandlearn.com/2015/12/executing-composite-soapui-project-from.html

https://github.com/suyogchoudhari/soapui-junit

【讨论】:

以上是关于Maven SoapUI 插件 - 如何在 Maven 的生命周期中执行 2 个 SoapUI 测试项目的主要内容,如果未能解决你的问题,请参考以下文章

eclipse pom文件报错 org.apache.maven.archiver.MavenArchiver.getManifest(org.apache.maven.project.Mav (Cl

eclipse集成maven

eclipse集成maven插件

Maven 插件不使用 Eclipse 的代理设置

用AntRun插件测试Maven的生命周期

SoapUI