allure--Automated test report generation

Source: Internet
Author: User
Tags testng

Previous attempts to use TestNG's own test reports, optimized reportng test reports, were not satisfactory for both reports. After looking for information, found that there is an artifact:

Allure (already has the Allure2, the author uses is Allure2), produces the test report with above two kinds of contrast, is simply perfect! The first test report of the chart, give you the intuitive feeling under:

Next, we'll teach you to use allure to generate your own high-profile test reports with failure cases, test steps, and test instructions.

The first step is to add dependencies in Maven and configure them accordingly:

 <Properties>        <aspectj.version>1.8.10</aspectj.version>    </Properties>    <Dependencies>        <Dependency>            <groupId>Io.qameta.allure</groupId>            <Artifactid>Allure-testng</Artifactid>            <version>2.6.0</version>            <Scope>Test</Scope>        </Dependency>        <Dependency>            <groupId>Org.aspectj</groupId>            <Artifactid>Aspectjweaver</Artifactid>            <version>${aspectj.version}</version>        </Dependency></Dependencies> <plugin>                <groupId>Org.apache.maven.plugins</groupId>                <Artifactid>Maven-surefire-plugin</Artifactid>                <version>2.10</version>                <Configuration>                    <!--Set parameters command line -                    <Argline>-javaagent: "${SETTINGS.LOCALREPOSITORY}/ORG/ASPECTJ/ASPECTJWEAVER/${ASPECTJ.VERSION}/ASPECTJW Eaver-${aspectj.version}.jar "</Argline>                    <Systempropertyvariables>                        <!--whether or not to ignore HTML, see the explanation. And later on the reportng report is displayed related. Allure is now in use, it can be removed directly . -                        <Org.uncommons.reportng.escape-output>False</Org.uncommons.reportng.escape-output>                    </Systempropertyvariables>                    <!--whether to ignore and continue testing after the test fails -                    <Testfailureignore>True</Testfailureignore>                    <Argline>-dfile.encoding=utf-8</Argline>                    <Suitexmlfiles>                        <!--represents the name of the test suite to be executed -                        <Suitexmlfile>Src/test/resources/testng.xml</Suitexmlfile>                    </Suitexmlfiles>                </Configuration>            </plugin>

Step two: Install the allure plugin in Jenkins "System Management"-"plug-in Management"-"optional plugins" to download and install allure, after installation restart. After the installation is successful, you can see it in system administration-plug-in management-installed plugins

Step three: Download Allure2 to Girhub, address: https://github.com/allure-framework/allure2/releases

After downloading, unzip to the appropriate directory, such as:

Fourth, set the installation address for allure in the "System Management"-"Global tools Configuration" of Jenkins:

Save it.

Once you have built and executed the test code through Jenkins, you can see the Allure test report. Above, complete the basic configuration of allure.

OK, allure can be used, next, we dig down the other useful points of the tool.

First: Build the failure case:

First step: On the test class, add listeners annotations

The second step: to achieve their own use cases of monitoring, monitoring after hearing

 Public class extends testlisteneradapter {       @Override    publicvoid  ontestfailure (itestresult Result) {        takephoto ();    }     = "screen shot", type = "Image/png")    publicbyte[]  Takephoto () {         byte [] Screenshotas = ((takesscreenshot) basetester.driver). Getscreenshotas (outputtype.bytes);         return Screenshotas;}    }

Using Allure's attachment annotations, you can implement the requirements shown in the report.

The third step is to configure the listener in the testng configuration file

Effectiveness such as:

Second: Displays the test description information.

In the test report, we expect to see the descriptive information for each case to make our testing process clearer.

You only need to assign a value to the description in the test note:

Effects such as:

is not very heart, hurry to try it!!

allure--Automated test report generation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.