【问题标题】:Invoke/Integrate SoapUI to an Automation Regression Test Project调用/集成 SoapUI 到自动化回归测试项目
【发布时间】:2017-01-15 21:09:31
【问题描述】:

我们正在使用 SoapUI 来触发 Web 服务。 现在,我正在创建一个自动化回归测试项目(Java、Maven、Selenium Webdirver)。有许多测试套件需要 SoapUI 在测试开始或中间发送 Web 服务请求。我想知道是否有一种方法可以导入 SoapUI 源代码或将 SoapUI jar 安装到我的项目中。所以我可以直接调用 SoapUI 函数或方法或类。 我已将这些依赖项添加到我的 pom.xml:

<dependency>
    <groupId>com.github.redfish4ktc.soapui</groupId>
    <artifactId>maven-soapui-extension-plugin</artifactId>
    <version>4.6.4.0</version>
</dependency>

<dependency>
    <groupId>net.java.dev.jgoodies</groupId>
    <artifactId>looks</artifactId>
    <version>2.1.4</version>
</dependency>
<dependency>
    <groupId>net.sf.squirrel-sql.thirdparty-non-maven</groupId>
    <artifactId>com-fifesoft-rsyntaxtextarea</artifactId>
    <version>1.0.0</version>
</dependency>
<dependency>
    <groupId>org.apache.karaf.eik.plugins</groupId>
    <artifactId>org.apache.commons.collections</artifactId>
    <version>3.2.1</version>
</dependency>

我还安装了 SoapUI Intellij Idea 插件。但似乎什么都没有改变。 感谢您的任何帮助和建议。或者如果有任何其他方法来实现此功能也会很棒。

【问题讨论】:

  • 这太宽泛了。您需要通过细节来缩小问题范围。
  • 对不起,我只想知道我需要做哪些准备工作?所以我可以直接使用soapUI源码的方法。
  • 同意@Rao 也许从文档开始? soapui.org/test-automation/junit/junit-integration.html
  • 从 SmartBear 社区得到答案。将所有 jar 和 soapUI jar 导入我的项目。抱歉,可能是我的错,我描述的不是很清楚。我只想通过我的项目运行soapUI。

标签: java automation automated-tests integration-testing soapui


【解决方案1】:

您似乎试图通过 Maven 运行soapUI。如果是这样,你的 pom.xml 应该包含 soapui-maven-pluginpluginRepository 。所以你的 pom.xml 应该如下所示。它还包括maven-surefire-report-plugin 以获取 HTML 类型的报告。您将不得不更改 <projectFile>sample-soapui-project.xml</projectFile> 以包含您的项目文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.test</groupId>
  <artifactId>mytest</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>mytest</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <pluginRepositories>
   <pluginRepository>
      <id>eviwarePluginRepository</id>
      <url>http://www.eviware.com/repository/maven2/</url>
   </pluginRepository>
</pluginRepositories>
<build>
<plugins>
  <plugin>
  <groupId>com.smartbear.soapui</groupId>
  <artifactId>soapui-maven-plugin</artifactId>
  <version>5.1.2-m-SNAPSHOT</version>
  <configuration>
    <!--soapUI project file location-->
    <projectFile>sample-soapui-project.xml</projectFile>
    <!--output file location-->
    <outputFolder>${project.basedir}/output/</outputFolder>
    <!--junit results file-->
    <junitReport>true</junitReport>
  </configuration>
  <executions>
    <execution>
      <id>soapUI</id>
      <phase>test</phase>
      <goals>
       <goal>test</goal>
      </goals>
    </execution>
  </executions>
  </plugin>
</plugins>
</build>
<reporting>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-report-plugin</artifactId>
        <version>2.18.1</version>
      </plugin>
    </plugins>
  </reporting>
</project>

【讨论】:

    【解决方案2】:

    从 C:\Program Files (x86)\SmartBear\SoapUI-5.2.1\lib 和 C:\Program Files\SmartBear\SoapUI-5.2.1\bin 导入所有的 soapUi jar 和 SoapUI.jar。

    public void runTestCase(String tarSuite, String tarCase) throws Exception {
    
        String reportStr = "";
    
        SoapUI.setSoapUICore(new StandaloneSoapUICore(true));
    
        WsdlProject project = new WsdlProject("C:\\Users\\tshi\\Documents\\Maven Projects\\ASORT\\WebServiceResource\\Suncorp_Issuing-soapui-project.xml");
    
        List<TestSuite> suiteList = project.getTestSuiteList();
    
        for (TestSuite aSuiteList : suiteList) {
    
            String suiteName = aSuiteList.getName();
    
            List<TestCase> caseList = aSuiteList.getTestCaseList();
            //System.out.println("Test Suite: " + suiteName);
    
            if (suiteName.equals(tarSuite)) {
    
                for (TestCase aCaseList : caseList) {
    
                    String caseName = aCaseList.getName();
                    //System.out.println("Test Case: " + caseName);
    
                    if (caseName.equals(tarCase)) {
    
                        long startTime = System.currentTimeMillis();
    
                        TestRunner runner = project.getTestSuiteByName(suiteName).getTestCaseByName(caseName).run(new PropertiesMap(), false);
    
                        long duration = System.currentTimeMillis() - startTime;
    
                        reportStr = reportStr + "\n\tTestCase: " + aCaseList.getName() + "\tStatus: " + runner.getStatus() + "\tReason: " + runner.getReason() + "\tDuration: " + duration;
    
                    }
    
                }
    
            }
    
        }
    
        System.out.print(reportStr);
    
    }
    

    这可能不是实现目标的最佳方式。但它实际上对我有用。所有设备都将受到欢迎。谢谢你们。

    【讨论】:

      猜你喜欢
      • 2021-06-13
      • 1970-01-01
      • 2016-05-19
      • 2012-08-09
      • 2016-11-25
      • 2010-10-05
      • 1970-01-01
      • 1970-01-01
      • 2023-03-18
      相关资源
      最近更新 更多