Create WebDriver HTML Reports With The Allure Framework

cats and html reports

 

Allure framework can help with generating HTML reports for your Selenium WebDriver projects.

The reporting framework is very flexible and it works with many programming languages and unit testing frameworks.

You can read everything about it at http://allure.qatools.ru/.

JUNIT does not provide any HTML reports by default

If you use JUNIT for running your test automation scripts,everything that you get is a visual report of the test results.

This visual report is GREEN if all the test scripts pass and RED if at least one test script fails.

 

For each test script, the execution status (pass/fail) is displayed, together with the execution time and details of the error.

The problems with this visual report are that

  • it cannot be saved
  • the amount of information that it includes is very limited
  • it is not possible to see over time how the test scripts run

The Allure framework has solutions for all these problems

The reports that can be generated using Allure are very impressive.
You can get
– an overview report for multiple test suites

 

– detailed report for a test suite

 

– graphical reports

 

See more report templates on this link:
http://ci.qatools.ru/job/allure-core_master-deploy/lastSuccessfulBuild/Allure_report/

How can you get these great reports for your WebDriver test scripts?

It is quite easy to add the Allure framework to your WebDriver project.

 

this is relevant

 

1. Create a Maven project in Eclipse

After creating the Maven project, the project structure will be as follows:

 

 

 

2. Add the class files to the proper folders

 

The page object classes should be in the Src/Main/Java folder.

The test script classes should go to the Test/Java folder.

 

 

3. Configure the POM xml file

 

The POM file is very straightforward:

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”&gt;

<modelVersion>4.0.0</modelVersion>

<groupId>com.siminiuc</groupId>

<artifactId>MavenProject</artifactId>

<version>0.0.1</version>

<name>Maven Project</name>

<url>http://maven.apache.org</url&gt;

<dependencies>

     <dependency>

              <groupId>junit</groupId>

              <artifactId>junit</artifactId>

              <version>4.12</version>

              <scope>test</scope>

      </dependency>

     <dependency>

              <groupId>org.seleniumhq.selenium</groupId>

             <artifactId>selenium-firefox-driver</artifactId>

             <version>2.47.1</version>

     </dependency>    

 </dependencies>  

 <build>

      <plugins>

           <plugin>

               <groupId>org.apache.maven.plugins</groupId>

              <artifactId>maven-compiler-plugin</artifactId>

              <version>2.3.2</version>

              <configuration>

                     <fork>true</fork>

                     <source>1.7</source>

                     <target>1.7</target>

                     <executable>C:\JDK\bin\javac.exe</executable>

            </configuration>

        </plugin>           

    </plugins>

</build>

</project>

             

It includes dependencies for JUNIT and Selenium Firefox driver and a plugin for the maven compiler.

 


selenium free course

4. Run the test scripts

 

 

Run the test scripts using maven test:

 

 

 

 

 

 

 

The execution results are displayed in the console tab:

 

5. Add Allure framework details to the POM file

 

The POM file changes a bit after adding the Allure details.

I have highlighted with italic all changes:

<project xmlns=”http://maven.apache.org/POM/4.0.0&#8243; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”&gt;

 <modelVersion>4.0.0</modelVersion>

 <groupId>com.siminiuc</groupId>

 <artifactId>MavenProject</artifactId>

 <version>0.0.1</version>

 <name>Maven Project</name>

 <url>http://maven.apache.org</url&gt;

 <properties>

         <aspectj.version>1.8.5</aspectj.version>

         <allure.version>1.4.11</allure.version>

 </properties>

 <dependencies>

        <dependency>

                 <groupId>junit</groupId>

                 <artifactId>junit</artifactId>

                 <version>4.12</version>

                 <scope>test</scope>

         </dependency>

         <dependency>

               <groupId>org.seleniumhq.selenium</groupId>

              <artifactId>selenium-firefox-driver</artifactId>

              <version>2.47.1</version>

        </dependency>

         <dependency>

               <groupId>ru.yandex.qatools.allure</groupId>

               <artifactId>allure-junit-adaptor</artifactId>

              <version>${allure.version}</version>

        </dependency>

</dependencies>  

 

cat awake

<build>

      <plugins>

                   <plugin>

                          <groupId>org.apache.maven.plugins</groupId>

                          <artifactId>maven-compiler-plugin</artifactId>

                          <version>2.3.2</version>

                         <configuration>

                                 <fork>true</fork>

                                 <source>1.7</source>

                                 <target>1.7</target>

                                 <executable>C:\JDK\bin\javac.exe</executable>

                       </configuration>

               </plugin>

              <plugin>

                           <groupId>org.apache.maven.plugins</groupId>

                          <artifactId>maven-surefire-plugin</artifactId>

                         <version>2.14</version>

                        <configuration>

                                  <testFailureIgnore>false</testFailureIgnore>

                                  <argLine>

                                       –                   javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar

                                 </argLine>

                                <properties>

                                     <property>

                                          <name>listener</name>                                         

                                          <value>

                                                      ru.yandex.qatools.allure.junit.AllureRunListener

                                          </value>

                                   </property>

                               </properties>

                     </configuration>
                      <dependencies>

                             <dependency>

                                      <groupId>org.aspectj</groupId>

                                     <artifactId>aspectjweaver</artifactId>

                                     <version>${aspectj.version}</version>

                            </dependency>

                    </dependencies>

        </plugin>

        <plugin>

               <groupId>org.eclipse.jetty</groupId>

               <artifactId>jetty-maven-plugin</artifactId>

               <version>9.2.10.v20150310</version>

               <configuration>

                       <webAppSourceDirectory>

                           ${project.build.directory}/site/allure-maven-plugin

                      </webAppSourceDirectory>

                      <stopKey>stop</stopKey>

                      <stopPort>1234</stopPort>

            </configuration>

     </plugin>

  </plugins>

</build>

<reporting>

                <excludeDefaults>true</excludeDefaults>

                <plugins>

                      <plugin>

                              <groupId>ru.yandex.qatools.allure</groupId>

                              <artifactId>allure-maven-plugin</artifactId>

                              <version>2.0</version>

                      </plugin>

             </plugins>

</reporting>

</project>

 


selenium free course

6. Run the test scripts in Command Prompt

 

 

 

7. Generate the report by running mvn site in the Command Prompt

 

 

The Allure report can be found on the following location:
C:\Users\home\workspace\AllureProject\target\site\allure-maven-plugin

 

 

The report can be displayed in the browser by double-clicking the index.html file:


selenium free course

Advertisements

14 Comments Add yours

  1. Hi. This looks exactly what I've been looking for! I've configured as per this post, however I get the following error – could you point me in the right direction please if you get time?
    Many thanks in advance
    Mark…

    Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.0:site (default-site) on project selenide-test-2015: failed to get report for ru.yandex.qatools.allure:allure-maven-plugin: Unable to load the mojo 'report' (or one of its required components) from the plugin 'ru.yandex.qatools.allure:allure-maven-plugin:2.0': com.google.inject.ProvisionException: Guice provision errors:
    [ERROR]
    [ERROR] 1) No implementation for org.eclipse.aether.RepositorySystem was bound.
    [ERROR] while locating ru.yandex.qatools.allure.report.AllureReportMojo
    [ERROR] at ClassRealm[plugin>ru.yandex.qatools.allure:allure-maven-plugin:2.0, parent: ClassRealm[plugin>org.apache.maven.plugins:maven-site-plugin:3.0, parent: sun.misc.Launcher$AppClassLoader@6d06d69c]]
    [ERROR] while locating org.apache.maven.plugin.Mojo annotated with @com.google.inject.name.Named(value=ru.yandex.qatools.allure:allure-maven-plugin:2.0:report)
    [ERROR]
    [ERROR] 1 error
    [ERROR] role: org.apache.maven.plugin.Mojo
    [ERROR] roleHint: ru.yandex.qatools.allure:allure-maven-plugin:2.0:report

    Like

  2. HI Mark,

    Sure, I can try to help.

    Please email me at alex@alexsiminiuc.com.

    Thanks.

    Alex

    Like

  3. Uday Thakur says:

    Hi Alex

    Any support for TestNG ?

    In my framework I am already using Report NG and Sure-fire plugin but wanted to give a try.

    Like

  4. Doug Major says:

    Hi Alex,

    Thanks for this tutorial, very helpful…I'm wondering if you have a similar explanation for creating the Allure HTML report from an imported Maven project in IntelliJ?

    I've updated the pom.xml file, all test run successfully, but the allure junit report is failing with the error log message below. Any insight would be greatly appreciated…thanks again.

    WARNING: Error injecting: ru.yandex.qatools.allure.report.AllureReportMojo

    com.google.inject.ProvisionException: Guice provision errors:

    1) No implementation for org.eclipse.aether.RepositorySystem was bound.
    while locating ru.yandex.qatools.allure.report.AllureReportMojo

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.0:site (default-site) on project allure-junit-example: failed to get report for ru.yandex.qatools.allure:allure-maven-plugin: Unable to load the mojo 'report' (or one of its required components) from the plugin 'ru.yandex.qatools.allure:allure-maven-plugin:2.0': com.google.inject.ProvisionException: Guice provision errors:
    [ERROR]
    [ERROR] 1) No implementation for org.eclipse.aether.RepositorySystem was bound.

    Like

  5. Hi Doug,

    I havent used IntelliJ so far so I cannot help much.

    This looks like a bug that you should submit here:
    https://github.com/allure-framework/allure-core/issues

    Hope this helps.

    Alex

    Like

  6. Dollar says:

    Good article. I have tried this earlier. just wanted to know, It doesn’t generate reports if we’re not executing through command line? And I couldn’t able to see a html report generated when I’m not using maven build tool (added jar to the buildpath). I only see few xml reports generated in the project

    Like

  7. Kalyani Haridasyam says:

    Can we convert the existing JUnit report/xml to allure report/xml?

    Like

  8. Kalyani says:

    Can we convert the existing JUnit xml to Allure xml?

    Like

  9. Stroev says:

    Hi Alex,
    Is it possible to add a time stamp when a report is generating, so the generated reports not to overwrite?

    Like

  10. Stroev says:

    Hi,
    This tool seems to be really cool. I’d like to give it try
    I have troubles configuring the POM and when I run the : mvn clean test site command I got ERRORs in the CONSOLE:
    Could anyone help?
    If someone is willing to give a hand with the configuration I could provide the POM information.

    Like

  11. vishal sharma says:

    I used the same but only xml files are created. No index.html file is found.
    I have not added anything in testng.xml.
    What could be the issue.

    Like

  12. Abhinav says:

    Could you please guide how can we convert the existing JUnit report/xml to allure report/xml or how can i map the xml report to allure framework? FYI, am not using maven central.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s