Failed to save search report popups with TestNG

I am trying to use Allure reports for my Selenium Webdriver + TestNG + Maven project. I used the AllureListener class as stated in Allure documentation and example . However, I am unable to set screenshots correctly for the report. Here are my observations:

  • I can only see * .xml files generated in target / allure-results , not screenshot files.
  • I see that the images are temporarily stored in the / temp folder and then deleted by the time the test execution report is generated. This means the screenshots are being stored in the wrong location, I suppose.

My requirement: I expect to save the screenshot files in the target location in allure-results instead of a temporary location. Therefore, I can control the reports as always. Also my TestNG results are also not generated at this stage. 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>

      

+3


source to share


2 answers


In order to make Allure functions like: attachments , steps and parameters work as expected , you need to correctly specify - javaagent . On Windows, use the following notation:

        <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>

      



Pay attention to the quotes around the path . Without the correct -javaagent specification , your @Attachment , @Step and @Parameter annotations will be ignored by Allure.

+2


source


It looks like Allure is unable to create the default folder allure-results

. Try pointing allure.results.directory

for some path:

<properties>
    <allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
</properties>
...
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.14</version>
    <configuration>
        <argLine>
            -javaagent:"${settings.localRepository}\org\aspectj\aspectjweaver\${aspectj.version}\aspectjweaver-${aspectj.version}.jar"
        </argLine>
        <!--only for 1.3.* TestNG adapters. Since 1.4.0.RC4 listener adds via ServiceLoader-->
        <properties>
            <property>
                <name>listener</name>
                <value>ru.yandex.qatools.junit.spi.RunListenerWeaver</value>
            </property>
        </properties>
        <systemProperties>
            <property>
                <name>allure.results.directory</name>
                <value>${allure.results.directory}</value>
            </property>
        </systemProperties>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>${aspectj.version}</version>
        </dependency>
    </dependencies>
</plugin>

      



The complete pom.xml is located at https://gist.github.com/baev/a47505208fc0214b833d

Note: you need to add allure-testng-dependency

+1


source







All Articles