当测试用例失败时,无法为Soap UI套件生成surefire报告:Maven

时间:2017-01-23 14:41:19

标签: maven jenkins jenkins-plugins soapui maven-surefire-plugin

当所有测试用例都使用pom传递时,会成功生成Junit和surefire报告。但是如果测试用例失败,则构建失败并且不会生成报告。我正在使用Maven构建和Jenkins作为CI工具。我正在运行一个Soap UI项目。请帮忙。我已经在网上探索了很多选项,但是即使测试用例失败(构建失败)也没有谈论成功生成surefire或junit报告。请注意:所有测试用例通过时都会生成一个漂亮的报告。下面是pom.xml。

我在Jenkins for Maven中配置的目标是干净的网站

此外,我尝试使用-Dmaven.test.failure.ignore = true作为MAVEN_OPTS,但它没有帮助。

<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>soapTest</groupId>
<artifactId>soapTest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Maven 2 SoapUI Sample</name>
<url>http://maven.apache.org</url>

<pluginRepositories>
    <pluginRepository>
        <id>SmartBearPluginRepository</id>
        <url>http://www.soapui.org/repository/maven2/</url>
    </pluginRepository> 
    <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</version>
            <configuration>
                <projectFile>C:\Users\xyz\.jenkins\workspace\Soap-uiTest\globalweather-soapui-project.xml</projectFile>
                <outputFolder>${basedir}/target/surefire-reports</outputFolder>
                <junitReport>true</junitReport>
                <exportAll>true</exportAll>
                <printReport>true</printReport>             

            </configuration>

            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

    <plugin>
    <!-- Extended Maven antrun plugin -->
    <!-- https://maven-antrun-extended-plugin.dev.java.net/ -->
    <groupId>org.jvnet.maven-antrun-extended-plugin</groupId>
    <artifactId>maven-antrun-extended-plugin</artifactId>
    <executions>
      <execution>
        <id>test-reports</id>
        <phase>test</phase>
        <configuration>
          <tasks>
            <junitreport todir="target/surefire-reports">
              <fileset dir="target/surefire-reports">
                <include name="**/*.xml"/>
              </fileset>
              <report format="noframes" todir="target/surefire-reports"/>
            </junitreport>
          </tasks>
        </configuration>
        <goals>
          <goal>run</goal>
        </goals>
      </execution>
    </executions>
    <dependencies>
      <dependency>
        <groupId>org.apache.ant</groupId>
        <artifactId>ant-junit</artifactId>
        <version>1.8.0</version>
      </dependency>
      <dependency>
        <groupId>org.apache.ant</groupId>
        <artifactId>ant-trax</artifactId>
        <version>1.8.0</version>
      </dependency>
    </dependencies>
  </plugin>     

  <plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-surefire-plugin</artifactId>
   <version>2.19.1</version>
   <configuration>
     <testFailureIgnore>true</testFailureIgnore>
   </configuration>
 </plugin>

</plugins>
</build>

<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-report-plugin</artifactId>
            <version>2.19.1</version>                       
        </plugin>
    </plugins>
</reporting>
</project>

========================================
Adding the errors from log:

SoapUI 5.1.2 TestCaseRunner Summary
-----------------------------
Time Taken: 2279ms
Total TestSuites: 2
Total TestCases: 2 (1 failed)
Total TestSteps: 4
Total Request Assertions: 5
Total Failed Assertions: 1
Total Exported Results: 4
[ERROR] java.lang.Exception: Valid HTTP Status Codes in [GetCitiesByCountry - Request 1] failed;
[Response status code:200 is not in acceptable list of status codes]
Status: FAILED
Time Taken: 1047
Size: 8038
Timestamp: Mon Jan 23 22:38:22 IST 2017
TestStep: GetCitiesByCountry - Request 1

----------------- Messages ------------------------------
[Valid HTTP Status Codes] Response status code:200 is not in acceptable list of status codes

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.3:site (default-site) on project soapTest: failed to get report for org.apache.maven.plugins:maven-surefire-report-plugin: Failed to execute goal com.smartbear.soapui:soapui-maven-plugin:5.1.2:test (default) on project soapTest: SoapUI Test(s) failed: SoapUI Test(s) failed:
[ERROR] Valid HTTP Status Codes in [GetCitiesByCountry - Request 1] failed;
[ERROR] [Response status code:200 is not in acceptable list of status codes]
[ERROR] Status: FAILED
[ERROR] Time Taken: 1047
[ERROR] Size: 8038
[ERROR] Timestamp: Mon Jan 23 22:38:22 IST 2017
[ERROR] TestStep: GetCitiesByCountry - Request 1
[ERROR] 
[ERROR] ----------------- Messages ------------------------------
[ERROR] [Valid HTTP Status Codes] Response status code:200 is not in acceptable list of status codes
[ERROR] 
[ERROR] ----------------- Properties ------------------------------
[ERROR] Endpoint: http://www.webservicex.com/globalweather.asmx
[ERROR] Encoding: UTF-8
[ERROR] 
[ERROR] ---------------- Request ---------------------------
[ERROR] Request Headers: SOAPAction : "http://www.webserviceX.NET/GetCitiesByCountry"
[ERROR] Connection : Keep-Alive
[ERROR] User-Agent : Apache-HttpClient/4.1.1 (java 1.5)
[ERROR] Host : www.webservicex.com
[ERROR] Accept-Encoding : gzip,deflate
[ERROR] Content-Length : 340
[ERROR] Content-Type : text/xml;charset=UTF-8
[ERROR] 
[ERROR] 
[ERROR] <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET">
[ERROR] <soapenv:Header/>
[ERROR] <soapenv:Body>
[ERROR] <web:GetCitiesByCountry>
[ERROR] <!--Optional:-->
[ERROR] <web:CountryName>INDIA</web:CountryName>
[ERROR] </web:GetCitiesByCountry>
[ERROR] </soapenv:Body>
[ERROR] </soapenv:Envelope>
[ERROR] 
[ERROR] ---------------- Response --------------------------
[ERROR] Response Headers: Cache-Control : private, max-age=0
[ERROR] Server : Microsoft-IIS/7.0
[ERROR] Content-Encoding : gzip
[ERROR] X-AspNet-Version : 4.0.30319
[ERROR] Vary : Accept-Encoding
[ERROR] #status# : HTTP/1.1 200 OK
[ERROR] Content-Length : 1293
[ERROR] Date : Mon, 23 Jan 2017 17:08:17 GMT
[ERROR] Content-Type : text/xml; charset=utf-8
[ERROR] X-Powered-By : ASP.NET
[ERROR] 
[ERROR] 
[ERROR] <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
[ERROR] <soap:Body>
[ERROR] <GetCitiesByCountryResponse xmlns="http://www.webserviceX.NET">
[ERROR] <GetCitiesByCountryResult><![CDATA[<NewDataSet>
[ERROR] <Table>
[ERROR] <Country>British Indian Ocean Territory</Country>
[ERROR] <City>Diego Garcia</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Ahmadabad</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Akola</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Aurangabad Chikalthan Aerodrome</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bombay / Santacruz</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bilaspur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bhuj-Rudramata</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Belgaum / Sambra</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bhopal / Bairagarh</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bhaunagar</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Goa / Dabolim Airport</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Indore</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Jabalpur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Khandwa</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Kolhapur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Nagpur Sonegaon</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Rajkot</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Sholapur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Agartala</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Siliguri</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bhubaneswar</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Calcutta / Dum Dum</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Car Nicobar</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Gorakhpur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Gauhati</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Gaya</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Imphal Tulihal</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Jharsuguda</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Jamshedpur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>North Lakhimpur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Dibrugarh / Mohanbari</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Port Blair</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Patna</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>M. O. Ranchi</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Agra</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Allahabad / Bamhrauli</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Amritsar</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Varanasi / Babatpur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bareilly</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Kanpur / Chakeri</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>New Delhi / Safdarjung</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>New Delhi / Palam</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Gwalior</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Hissar</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Jhansi</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Jodhpur</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Jaipur / Sanganer</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Kota Aerodrome</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Lucknow / Amausi</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Satna</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Udaipur Dabok</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Bellary</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Vijayawada / Gannavaram</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Coimbatore / Peelamedu</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Cochin / Willingdon</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Cuddapah</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Hyderabad Airport</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Madurai</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Mangalore / Bajpe</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Madras / Minambakkam</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Tiruchchirapalli</City>
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Thiruvananthapuram</City>
[JENKINS] Archiving C:\Users\chandan.gupta\.jenkins\workspace\Soap-uiTest\pom.xml to soapTest/soapTest/1.0-SNAPSHOT/soapTest-1.0-SNAPSHOT.pom
[ERROR] </Table>
[ERROR] <Table>
[ERROR] <Country>India</Country>
[ERROR] <City>Vellore</City>
[ERROR] </Table>
[ERROR] </NewDataSet>]]></GetCitiesByCountryResult>
[ERROR] </GetCitiesByCountryResponse>
[ERROR] </soap:Body>
[ERROR] </soap:Envelope>
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

1 个答案:

答案 0 :(得分:0)

我通过添加

来解决这个问题
<testFailIgnore>true</testFailIgnore>

到soapui-maven-plugin,如下所示

<plugin>
            <groupId>com.smartbear.soapui</groupId>
            <artifactId>soapui-maven-plugin</artifactId>
            <version>5.1.2</version>
            <configuration>
                <projectFile>C:\Users\xyz\.jenkins\workspace\Soap-uiTest\globalweather-soapui-project.xml</projectFile>
                <outputFolder>${basedir}/target/surefire-reports</outputFolder>
                <junitReport>true</junitReport>
                <exportAll>true</exportAll>
                <printReport>true</printReport>     
                <testFailIgnore>true</testFailIgnore>           
                <!--testSuite>Business test cases</testSuite-->               
            </configuration>

            <executions>
                <execution>
                    <phase>test</phase>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>   

之前我已将相同的内容添加到maven-surefire-plugin中,但这并不起作用。谢谢大家!