如何将soapUI与Jenkins集成?

如何将soapUI与Jenkins集成?,soap,hudson,jenkins,soapui,Soap,Hudson,Jenkins,Soapui,有人知道将soapUI测试添加到我的CI构建中的好方法吗?soapUI通过Maven或Ant提供测试自动化。描述了Maven集成 我在几个月前尝试过,但在eviware存储库中出现了一些奇怪的问题。。。因此,我现在通过Ant运行测试。您需要做的是调用soapUI-bin目录中的testrunner.bat(或testrunner.sh)脚本。您可以找到可用的参数 您必须在Hudson构建服务器上安装soapUI。然后,您只需创建一个通过Ant构建的新作业 示例build.xml: <pro

有人知道将soapUI测试添加到我的CI构建中的好方法吗?

soapUI通过Maven或Ant提供测试自动化。描述了Maven集成

我在几个月前尝试过,但在eviware存储库中出现了一些奇怪的问题。。。因此,我现在通过Ant运行测试。您需要做的是调用soapUI-bin目录中的
testrunner.bat
(或
testrunner.sh
)脚本。您可以找到可用的参数

您必须在Hudson构建服务器上安装soapUI。然后,您只需创建一个通过Ant构建的新作业

示例
build.xml

<project name="IntegrationTest" default="soapui-tests" basedir=".">
    <description>Runs the soapUI integration tests</description>
    <property file="build.properties"/>

    <target name="checkos">
        <condition property="testrunner.cmd" value="${soapUI.home}/bin/testrunner.bat">
                <os family="windows" />
        </condition>
        <condition property="testrunner.cmd" value="${soapUI.home}/bin/testrunner.sh">
                <os family="unix" />
        </condition>
    </target>

    <target name="soapui-tests" depends="checkos">
        <exec executable="${testrunner.cmd}"
              failonerror="yes"
              failifexecutionfails="yes"
        >    
            <arg value="-e ${service.endpoint}"/>
            <arg value="-P dbUrl=${db.Url}"/>
            <arg value="-rajf"/>
            <arg path="${report.dir}"/>
            <arg path="${soapui.project.folder}"/>
        </exec>
    </target>
</project>

运行soapUI集成测试

以下脚本作为hudson内自定义构建脚本的一部分被调用,该脚本向其传递要调用测试的目标主机的名称

#!/bin/bash -x

#
#   Regression Test Script for performing regression testing
#   
#   Note: Caution should be exercised where more than one set
#   of test suites exist in the same soapui project
#
#   Script invokes SOAPUI testrunner to perform tests
#
#   Script arguments:
#       target host
#

if [ $# -ne 1 ];
then
    echo "Usage: $0 target_host"
    exit 1
fi
TargetHost=$1
curdir=`pwd`
ProjectFile=$curdir/testing/SoapUI/YourProject.xml
SOAPUI_HOME=/soapuipath/soapui
TEST_RUNNER=testrunner.sh

if [ ! -f "$ProjectFile" ];
then
    echo "Project File does not exist"
    exit 1
fi
###############################################################################################
## Check the status of the last shell operation and if failed exit
###############################################################################################

## --------------------------------------------------------------------------------
##  Return the operating system pathname for the datafiles for the specified database
##
##  Arguments:
##      The return value to check.  zero indicates all is good.  Non-zero indicates error
##      The error message to display when exiting
##      
##  Exits if error detected
check_status()
{
    if [ $# -ne 2 ];
    then
        echo "$0: Programming error: Report to sysadmin@yourdomain.com"
        exit -1
    fi
    exit_code=$1
    err_msg=$2
    if [ $exit_code -ne 0 ];
    then
        echo $err_msg
        exit $exit_code
    fi
}


cd $SOAPUI_HOME/bin
bash -x ./$TEST_RUNNER -s"TestSuite 1" -c"TestCase 1 - Sanity Tests" -ehttps://$TargetHost:port/testurl "$ProjectFile"
check_status $? "Failed to pass regression testing "

cd "$curdir"

为什么不使用JUnit集成呢?

编辑:我们使用这种方法得到了一些奇怪的性能数据(秒而不是毫秒),结果表明这是因为使用了SoapUI运行程序。在SoapUI中运行相同的负载测试得到了正确的结果。也许我们没有正确使用API(尽管它看起来很简单)。我们转而使用ContiPerf2和客户机代码(无论如何我们都必须生成)来运行测试并获得正常结果。

我使用-它比官方的Maven插件好得多。只需将其配置为生成JUnit风格的结果,以便jenkins能够获取这些结果。

这非常简单

使用以下内容创建git回购(示例):

pom.xml,根据需要进行调整:

<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>
    <name>Test soapui</name>
    <groupId>tdrury</groupId>
    <artifactId>com.example.soapuitests</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <description>blah blah</description>
    <build>
        <plugins>
            <plugin>
                <groupId>com.smartbear.soapui</groupId>
                <artifactId>soapui-maven-plugin</artifactId>
                <version>5.0.0</version>

                <executions>
                    <execution>
                        <id>RestAPI-positiveTestSuite</id>
                        <configuration>
                            <projectFile>RestAPI-positiveTestSuite.xml</projectFile>
                            <outputFolder>target/surefire-reports</outputFolder>
                            <testSuite>Positive cases</testSuite>
                            <junitReport>true</junitReport>
                            <exportwAll>true</exportwAll>
                            <printReport>true</printReport>
                            <testFailIgnore>true</testFailIgnore>
                        </configuration>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>

                    <execution>
                        <id>RestAPI-negativeTestSuite</id>
                        <configuration>
                            <projectFile>RestAPI-negativeTestSuite.xml</projectFile>
                            <outputFolder>target/surefire-reports</outputFolder>
                            <testSuite>Negative tests</testSuite>
                            <junitReport>true</junitReport>
                            <exportwAll>true</exportwAll>
                            <printReport>true</printReport>
                            <testFailIgnore>true</testFailIgnore>
                        </configuration>

                        <goals>
                            <goal>test</goal>
                        </goals>

                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

4.0.0
测试soapui
特德鲁里
com.example.soapuitests
1.0-快照
罐子
废话
com.smartbear.soapui
soapui maven插件
5.0.0
RestAPI阳性测试套件
RestAPI-positiveTestSuite.xml
目标/surefire报告
阳性病例
真的
真的
真的
真的
测试
测试
RestAPI negativeTestSuite
RestAPI-negativeTestSuite.xml
目标/surefire报告
阴性试验
真的
真的
真的
真的
测试
测试
在Jenkins中创建一个新的Maven作业,并将其指向git repo和pom.xml,作为目标填充
test


这就是所有的人

所以我把我的SOAPUI测试作为单元测试来运行?如果这样做有效,我只能假设它也会生成Jenkins/hudson可以可视化的报告?是的,这就是我们所做的。就像普通的单元测试一样。不过,不会生成特殊报告,只是失败或成功。我们确实编写了一些代码从soap运行程序中提取日志,以显示测试失败的原因,但这只是几行。pom.xml示例末尾缺少标记我想应该是Jenkins如何将值注入build.xml中的变量
${endpoint}
?非常感谢。
<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>
    <name>Test soapui</name>
    <groupId>tdrury</groupId>
    <artifactId>com.example.soapuitests</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <description>blah blah</description>
    <build>
        <plugins>
            <plugin>
                <groupId>com.smartbear.soapui</groupId>
                <artifactId>soapui-maven-plugin</artifactId>
                <version>5.0.0</version>

                <executions>
                    <execution>
                        <id>RestAPI-positiveTestSuite</id>
                        <configuration>
                            <projectFile>RestAPI-positiveTestSuite.xml</projectFile>
                            <outputFolder>target/surefire-reports</outputFolder>
                            <testSuite>Positive cases</testSuite>
                            <junitReport>true</junitReport>
                            <exportwAll>true</exportwAll>
                            <printReport>true</printReport>
                            <testFailIgnore>true</testFailIgnore>
                        </configuration>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>

                    <execution>
                        <id>RestAPI-negativeTestSuite</id>
                        <configuration>
                            <projectFile>RestAPI-negativeTestSuite.xml</projectFile>
                            <outputFolder>target/surefire-reports</outputFolder>
                            <testSuite>Negative tests</testSuite>
                            <junitReport>true</junitReport>
                            <exportwAll>true</exportwAll>
                            <printReport>true</printReport>
                            <testFailIgnore>true</testFailIgnore>
                        </configuration>

                        <goals>
                            <goal>test</goal>
                        </goals>

                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>