GithubHelp home page GithubHelp logo

amitsha256 / allure-reporting-demo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 44 KB

This repository is for demonstrating allure reporting for cucumber jvm and JUnit4

License: MIT License

Java 84.01% Gherkin 15.99%

allure-reporting-demo's Introduction

To use Allure, you only need to complete two steps:

  1. Gather information about tests
    1. For this, there are adapters for different test frameworks like JUnit, Cucumber-JVM etc.
  2. Generate a report
    1. Few ways to generate the report:
      1. Allure command line
      2. Team City
      3. Jenkins etc. This is the easiest set up:

To generate the Allure compatible XML (Which is generated per test class):

Add the following plugins in your POM xml:

<plugin>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.2.0</version>
    <executions>
        <execution>
            <id>generateRunners</id>
            <phase>generate-test-sources</phase>
            <goals>
                <goal>generateRunners</goal>
            </goals>
            <configuration>
                <!-- Mandatory -->
                <!-- comma separated list of package names to scan for glue code -->
                <glue>com.amitsh.allure</glue>
                <!-- These are optional, with the default values -->
                <!-- Where to output the generated tests -->
                <outputDirectory>${project.build.directory}/generated-test-sources/cucumber</outputDirectory>
                <!-- The directory, which must be in the root of the runtime classpath, containing your feature files.  -->
                <featuresDirectory>src/test/resources/features/</featuresDirectory>
                <!-- Directory where the cucumber report files shall be written  -->
                <cucumberOutputDir>target/cucumber-parallel</cucumberOutputDir>
                <!-- comma separated list of output formats -->
                <format>json</format>
                <!-- CucumberOptions.strict property -->
                <strict>true</strict>
                <!-- CucumberOptions.monochrome property -->
                <monochrome>true</monochrome>
                <!-- The tags to run, maps to CucumberOptions.tags property -->
                <tags>"@amit"</tags>
                <!-- If set to true, only feature files containing the required tags shall be generated. -->
                <filterFeaturesByTags>false</filterFeaturesByTags>
                <!-- Generate TestNG runners instead of JUnit ones. -->
                <useTestNG>false</useTestNG>
                <!-- The naming scheme to use for the generated test classes.  One of 'simple' or 'feature-title' -->
                <namingScheme>simple</namingScheme>
                <!-- The class naming pattern to use.  Only required/used if naming scheme is 'pattern'.-->
                <namingPattern>Parallel{c}IT</namingPattern>
                <!-- One of [SCENARIO, FEATURE]. SCENARIO generates one runner per scenario.  FEATURE generates a runner per feature. -->
                <parallelScheme>SCENARIO</parallelScheme>
                <cucumberOptions>--plugin ru.yandex.qatools.allure.cucumberjvm.AllureReporter</cucumberOptions>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-failsafe-plugin</artifactId>
    <version>2.19.1</version>
    <executions>
        <execution>
            <phase>integration-test</phase>
            <goals>
                <goal>integration-test</goal>
            </goals>
            <configuration>
                <forkCount>1</forkCount>
                <reuseForks>false</reuseForks>
                <includes>
                    <include>**/*IT.java</include>
                </includes>
            </configuration>
        </execution>
    </executions>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.19.1</version>
    <configuration>
        <skipTests>false</skipTests>
        <properties>
            <property>
                <name>listener</name>
                <value>ru.yandex.qatools.allure.junit.AllureRunListener</value>
            </property>
        </properties>
    </configuration>
    <dependencies>
        <dependency>
            <groupId>org.apache.maven.surefire</groupId>
            <artifactId>surefire-junit4</artifactId>
            <version>2.19.1</version>
        </dependency>
    </dependencies>
</plugin>

Also, add these dependencies:

<!--Cucumber parallel plugin-->
<dependency>
    <groupId>com.github.temyers</groupId>
    <artifactId>cucumber-jvm-parallel-plugin</artifactId>
    <version>2.2.0</version>
</dependency>

<!--Allure dependencies-->
<dependency>
    <groupId>ru.yandex.qatools.allure</groupId>
    <artifactId>allure-cucumber-jvm-adaptor</artifactId>
    <version>1.6.1</version>
</dependency>

<dependency>
    <groupId>ru.yandex.qatools.allure</groupId>
    <artifactId>allure-junit-adaptor</artifactId>
    <version>1.5.0</version>
</dependency>

Obviously, you’ll need to add the other dependencies like cucumber-java etc.
With this set up, when you execute mvn test, unit tests will be executed and the xml report will get generated. When you execute mvn verify, unit tests and cucumber tests will be executed and the xml reports will get generated for unit test and the cucumber scenarios. It’s generated in target/allure-results.
For generating reports, cd into the project dir, and execute this command: allure generate target/allure-results. A folder allure-report will be generated in the project dir. Then execute allure report open to start the web server and launch the html report.

allure-reporting-demo's People

Watchers

Amit Sharma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.