无法使用TestNG保存诱人的报告摘要 [英] Unable to save allure report screeshots using TestNG
问题描述
我正在尝试对Selenium Webdriver + TestNG + Maven项目使用Allure报告.我使用了Allure文档和 example 中指定的AllureListener类.但是,我无法将屏幕截图正确附加到报告中.这是我的观察结果:
I am attempting to use Allure reporting for my Selenium Webdriver + TestNG + Maven project. I used AllureListener class as specified in Allure documentation and in example. However I am unable to get screenshots correctly attached to report. Here are my observations:
- 我只能看到 target/allure-results (目标/魅力结果)中生成的 *.xml文件,而不能查看截图文件.
- 我看到图像被临时存储在/temp文件夹中,然后在生成测试执行报告时被删除.这意味着屏幕快照图像存储在我认为错误的位置.
- I am able to see only *.xml files generated in target/allure-results, not the screenshot files.
- I see that images are temporarily stored in /temp folder and then get deleted by the time the test execution report is generated. That means the screenshot images are stored in wrong location I suppose.
我的要求:我希望将屏幕快照文件存储在目标位置的魅力结果中,而不是临时位置中.因此,我可以随时控制报告.另外,我的TestNG结果目前还没有生成.此时我在做错什么吗?
My requirement: I am expecting to store the screenshot files in the target location in allure-results instead of the temp location. So I can take control of the reports as anytime wanted. Also my TestNG results are also not generated at this point. Am I doing something wrong at this point?
<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>AllureProj</groupId>
<artifactId>AllureProj</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<compiler.version>1.7</compiler.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<allure.version>1.4.0.RC3</allure.version>
<aspectj.version>1.8.1</aspectj.version>
<settings.localRepository>C:/Users/steve/.m2/repository </settings.localRepository>
<aetherVersion>0.9.0.M2</aetherVersion>
<mavenVersion>3.1.0</mavenVersion>
<wagonVersion>2.6</wagonVersion>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<argLine>
<!-- -javaagent:F:\\Selenium\\Workspace\\AllureProj\lib\\aspectjweaver-1.7.4.jar -->
-javaagent:F:/Selenium/Workspace/AllureProj/lib/aspectjweaver-1.8.1.jar
<!-- -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar -->
</argLine>
<properties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.sonar</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>4.0</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-maven-plugin</artifactId>
<version>${allure.version}</version>
<configuration>
<outputDirectory>F:\\Selenium\\Workspace\\AllureOSP\\target\\allure-results</outputDirectory>
<allureResultsDirectory>F:\\Selenium\\Workspace\\AllureOSP\\target\\allure-results</allureResultsDirectory>
</configuration>
</plugin>
</plugins>
</reporting>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.42.2</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-firefox-driver</artifactId>
<version>2.42.0</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-testng-adaptor</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>com.github.detro</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.2.0</version>
</dependency>
<dependency>
<groupId>com.github.detro.ghostdriver</groupId>
<artifactId>phantomjsdriver</artifactId>
<version>1.0.4</version>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-all</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>net.anthavio</groupId>
<artifactId>phanbedder-1.9.7</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-java-annotations</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-java-aspects</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-report-data</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-java-commons</artifactId>
<version>${allure.version}</version>
</dependency>
<dependency>
<groupId>ru.yandex.qatools.allure</groupId>
<artifactId>allure-commons</artifactId>
<version>1.4.0.RC4</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.8.5</version>
</dependency>
</dependencies>
</project>
推荐答案
为了创建这样的诱人功能,例如:附件,步骤和参数正常工作,您需要正确指定 -javaagent 参数.在Windows下,以下 表示法应该起作用:
In order to make such Allure features like: attachments, steps and parameters work as expected you need to correctly specify -javaagent argument. Under Windows the following notation should work:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<argLine>
-javaagent:"${settings.localRepository}\org\aspectj\aspectjweaver\${aspectj.version}\aspectjweaver-${aspectj.version}.jar"
</argLine>
<properties>
<property>
<name>listener</name>
<value>ru.yandex.qatools.allure.testng.AllureTestListener</value>
</property>
</properties>
</configuration>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
</plugin>
请注意在路径周围加引号.如果没有正确的 -javaagent 规范,Allure将忽略您的 @Attachment , @Step 和 @Parameter 注释.
Note quotes around path. Without correct -javaagent specification your @Attachment, @Step and @Parameter annotations will be ignored by Allure.
这篇关于无法使用TestNG保存诱人的报告摘要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!