Invoke/Integrate SoapUI 到自动化回归测试项目
Invoke/Integrate SoapUI to an Automation Regression Test Project
我们正在使用 SoapUI 来触发网络服务。
现在,我正在创建一个自动化回归测试项目(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 Plugin。但似乎没有任何改变。
感谢您的帮助和建议。或者,如果有任何其他方法来实现此功能也将很棒。
您似乎试图通过 Maven 运行 soapUI。如果是这样,您 pom.xml 应该包含 soapui-maven-plugin
和 pluginRepository
。所以你的 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>
从 C:\Program Files (x86)\SmartBear\SoapUI-5.2.1\lib 和 C:\Program Files\SmartBear\SoapUI-5 导入所有 soapUi jar 和 SoapUI.jar。 2.1\bin.
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);
}
这可能不是实现目标的最佳方式。但它实际上对我有用。所有设备都将受到欢迎。谢谢你们。
我们正在使用 SoapUI 来触发网络服务。 现在,我正在创建一个自动化回归测试项目(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 Plugin。但似乎没有任何改变。 感谢您的帮助和建议。或者,如果有任何其他方法来实现此功能也将很棒。
您似乎试图通过 Maven 运行 soapUI。如果是这样,您 pom.xml 应该包含 soapui-maven-plugin
和 pluginRepository
。所以你的 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>
从 C:\Program Files (x86)\SmartBear\SoapUI-5.2.1\lib 和 C:\Program Files\SmartBear\SoapUI-5 导入所有 soapUi jar 和 SoapUI.jar。 2.1\bin.
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);
}
这可能不是实现目标的最佳方式。但它实际上对我有用。所有设备都将受到欢迎。谢谢你们。