如何在pom.xml中传递外部groovy脚本(Soapui和Maven Integration)

时间:2014-09-18 19:10:37

标签: maven groovy soapui

我的pom.xml在这里有project.xml和soapui-setting.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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com</groupId>
    <artifactId>SOAPUI</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>SOAPUI</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.oracle</groupId>
            <artifactId>ojdbc6</artifactId>
            <version>11.2.0</version>
        </dependency>
    </dependencies>
    <pluginRepositories>
        <pluginRepository>
            <id>smartbear-sweden-plugin-repository</id>
            <url>http://www.soapui.org/repository/maven2/</url>
        </pluginRepository>
    </pluginRepositories>
    <build>
        <plugins>
            <plugin>
                <groupId>com.smartbear.soapui</groupId>
                <artifactId>soapui-pro-maven-plugin</artifactId>
                <version>4.6.2</version>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <goals>
                            <goal>test</goal>
                        </goals>
                        <configuration>
                            <projectFile>SOAPUI-soapui-project.xml</projectFile>
                            <junitReport>true</junitReport>
                            <outputFolder>reports\</outputFolder>
                            <testSuite>UVConnect_Users</testSuite>
                            <testCase>TC_DECE_00001_UV_UserCreate_Adult_FAU_TOU_NotAccepted</testCase>
                            <settingsFile>C:\Users\omkar.khatavkar\soapui-settings.xml</settingsFile>
                            <soapuiProperties>
                                <property>
                                    <name>soapui.scripting.library</name>
                                    <value>C:\Scripts</value>
                                </property>
                            </soapuiProperties>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

但是在将mvn测试作为maven目标后,它会因为不理解而失败。

有什么办法可以将外部写入的groovy脚本传递给Soap ui Maven命令行目标吗?

00:25:00,371 ERROR [SoapUI] An error occurred [startup failed:
Script1.groovy: 15: unable to resolve class dbUtils.dbUtils
 @ line 15, column 9.
   def a = new dbUtils.dbUtils(log,dBHost);
           ^`enter code here`

2 个答案:

答案 0 :(得分:0)

  

...在给予mvn测试之后......

应该是:mvn com.smartbear.soapui:soapui-maven-plugin:test,对吧?

  

有什么办法可以将外部编写的groovy脚本传递给Soap ui Maven命令行目标吗?

有两种选择:

  1. 如果您有-Pro版本(从您的pom看起来像),您可以使用Script Library。请注意如何指定路径,以便它可以在CI机器上运行!
  2. 将脚本编译为jar并将其指定为dependency in the soapui-maven-plugin in your pom
  3. 您可能需要阅读SoapUI docs

答案 1 :(得分:0)

我添加了我缺少的Script和Ext文件夹的路径。这是我更新的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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com</groupId>
<artifactId>SOAPUI</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>SOAPUI</name>
<url>http://maven.apache.org</url>
<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<pluginRepositories>
    <pluginRepository>
        <id>smartbear-sweden-plugin-repository</id>
        <url>http://www.soapui.org/repository/maven2/</url>
    </pluginRepository>
</pluginRepositories>
<build>
    <plugins>
        <plugin>
            <groupId>com.smartbear.soapui</groupId>
            <artifactId>soapui-pro-maven-plugin</artifactId>
            <version>4.6.1</version>
            <dependencies>
                <dependency>
                    <groupId>com.oracle</groupId>
                    <artifactId>ojdbc6</artifactId>
                    <version>11.2.0</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                    <configuration>
                        <projectFile>SOAPUI-soapui-project.xml</projectFile>
                        <junitReport>true</junitReport>
                        <outputFolder>reports\</outputFolder>
                        <testSuite>UVConnect_Users</testSuite>
                        <testCase>TC_DECE_00001_UV_UserCreate_Adult_FAU_TOU_NotAccepted</testCase>
                        <settingsFile>C:\Users\omkar.khatavkar\soapui-settings.xml</settingsFile>
                        <soapuiProperties>
                            <property>
                                <name>soapui.scripting.library</name>
                                <value>C:\Scripts</value>
                            </property>
                            <property>
                                <name>soapui.ext.libraries</name>
                                <value>C:\Program Files\SmartBear\SoapUI-Pro-4.6.1\lib</value>
                            </property>
                        </soapuiProperties>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>