使用surefire插件和postman插件,如果测试用例通过,我可以向收件人发送带附件的电子邮件。在测试用例失败时,我收到以下错误。我不知道自己错过了什么。请帮忙。
无法执行目标org.apache.maven.plugins:maven-surefire-plugin:2.18.1:项目FSmaven1上的test(default-test):测试失败。
</project><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.ymedia</groupId>
<artifactId>FSmaven1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>FSmaven1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.48.2</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.53.0</version>
</dependency>
<dependency>
<groupId>com.uttesh</groupId>
<artifactId>pdfngreport</artifactId>
<version>2.1.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<!-- Suirefire plugin to run xml files -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<suiteXmlFiles>
<!-- TestNG suite XML files -->
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<!-- Post-Man plugin -->
<plugin>
<groupId>ch.fortysix</groupId>
<artifactId>maven-postman-plugin</artifactId>
<executions>
<execution>
<id>send a mail</id>
<phase>test</phase>
<goals>
<goal>send-mail</goal>
</goals>
<inherited>true</inherited>
<configuration>
<!-- From Email address -->
<from>XXX</from>
<!-- Email subject -->
<subject>Test Automation Report</subject>
<!-- Fail the build if the mail doesnt reach -->
<failonerror>false</failonerror>
<!-- host -->
<mailhost>smtp.gmail.com</mailhost>
<!-- port of the host -->
<mailport>465</mailport>
<mailssl>true</mailssl>
<mailAltConfig>true</mailAltConfig>
<!-- Email Authentication(USername and Password) -->
<mailuser>xxx</mailuser>
<mailpassword>xxx</mailpassword>
<receivers>
<!-- To Email address -->
<receiver>xxx</receiver>
</receivers>
<fileSets>
<fileSet>
<!-- Report directory Path -->
<directory>./reports</directory>
<includes>
<!-- Report file name -->
<include>*.pdf</include>
</includes>
<!-- Use Regular Expressions like **/*.html if you want all the html files to send-->
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
答案 0 :(得分:0)
尝试将Maven Failsafe plugin添加到您的版本中。它允许在测试失败的情况下安全执行。如果这对您有用,请告诉我们。
修改1 您还可以尝试将<testFailureIgnore>true</testFailureIgnore>
添加到Surefire插件配置中吗?
答案 1 :(得分:0)
您的Maven执行永远不会到达邮件发送插件,因为有测试失败。在maven-surefire-plugin的配置部分添加以下行:
<testErrorIgnore>true</testErrorIgnore>
<testFailureIgnore>true</testFailureIgnore>
这应该可以解决你的问题。