MacOS + idea configuration Maven + reportng

Source: Internet
Author: User
Tags stack trace testng

Using testng to do interface automation, testng Report template is not particularly beautiful, so found the reportng.

First, add reportng in Maven's Pom.xml (the latest version is 1.1.4)

<dependencies>    <dependency>        <groupId>org.uncommons</groupId>        < artifactid>reportng</artifactid>        <version>1.1.4</version>        <scope>test</ scope>        <exclusions>            <exclusion>                <groupId>org.testng</groupId>                < artifactid>testng</artifactid>            </exclusion>        </exclusions>    </dependency ></dependencies>

Note: You may encounter "ClassNotFoundExpection:com.google.inject.Module" issues with testng6.0+, you must add guice here, and continue adding them in the Pom.xml file.

<dependency>    <groupId>com.google.inject</groupId>    <artifactid>guice</ artifactid>    <version>3.0</version>    <scope>test</scope></dependency>

Second, add surefire plug-in

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-surefire-plugin</artifactId> <version>2.5</version> <configuration> <properties> <property> &L T;name>usedefaultlisteners</name> <value>false</value> </property> <property> <name&gt ;listener</name> <value>org.uncommons.reportng.htmlreporter, Org.uncommons.reportng.JUn itxmlreporter</value> </property> </properties> <wor kingdirectory>target/</workingdirectory> </configuration> </plugin> </plugins ></build>

At this point, the most basic reportng report templates and additions are completed

Third, the demonstration

Here is an example of an HTTP interface test I wrote earlier:

Http://www.cnblogs.com/testJocab/p/5438585.html

1. Open the terminal and go to the idea test Project root directory

2. Run the command: MVN clean test, the following is the output content

[INFO] Scanning forprojects ...                                                                         [INFO] [INFO]------------------------------------------------------------------------[INFO] Building maven1.0-Snapshot[info]------------------------------------------------------------------------Downloading:https://Repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom Downloaded:https://Repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom (4 KB at 1.0 kb/sec)[INFO] [INFO]---maven-clean-plugin:2.5:clean (default-clean) @ Maven---[INFO] Deleting/users/zhangbin/ideaprojects/httptest/Target[info] [INFO]---maven-resources-plugin:2.6:resources (default-resources) @ Maven---[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent![INFO] Copying0Resource[info] [INFO]---maven-compiler-plugin:3.1:compile (default-compile) @ Maven---[INFO] nothing to compile-All classes is up to date[info] [INFO]---maven-resources-plugin:2.6:testresources (default-testresources) @ Maven---[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent![INFO] Skip non existing resourcedirectory/users/zhangbin/ideaprojects/httptest/src/test/Resources[info] [INFO]---maven-compiler-plugin:3.1:testcompile (default-testcompile) @ Maven---[INFO] Changes detected-Recompiling the module![WARNING] File encoding have not been set, using platform encoding UTF-8, i.e. build is platform dependent![INFO] Compiling2 Source Files to/users/zhangbin/ideaprojects/httptest/target/test-Classes[info] [INFO]---maven-surefire-plugin:2.5:test (default-test) @ Maven---Downloading:https://Repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.0.9/maven-toolchain-2.0.9.jarDownloaded:https://Repo.maven.apache.org/maven2/org/apache/maven/maven-toolchain/2.0.9/maven-toolchain-2.0.9.jar (up to 14.2 kb /SEC)Downloading:https://Repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.5/surefire-testng-2.5.pomDownloaded:https://Repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.5/surefire-testng-2.5.pom (3 KB at 1.8 kb/sec)Downloading:https://Repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.5/surefire-providers-2.5.pom Downloaded:https://Repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-providers/2.5/surefire-providers-2.5.pom (2 KB at 2.1 kb/sec)Downloading:https://Repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.5/surefire-testng-2.5.jarDownloaded:https://Repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-testng/2.5/surefire-testng-2.5.jar (KB at 8.3 kb/sec)[INFO] Surefire Report Directory:/users/zhangbin/ideaprojects/httptest/target/surefire-reports-------------------------------------------------------T E s T s-------------------------------------------------------Running TestSuite=======this is beforeclass=======http://gateway.zitech.com/gw/oauthentry/study.scene/1.0/getbysid?access_token=bb801ee6b9983c7f893473fd6a313ad2 &subject_id=1http//gateway.zitech.com/gw/oauthentry/study.scene/1.0/getbysid?access_token=bb801ee6b9983c7f893473fd6a313ad2 &SUBJECT_ID=1%2C2http//gateway.zitech.com/gw/oauthentry/study.scene/1.0/getbysid?access_token=bb801ee6b9983c7f893473fd6a313ad2 &subject_id=123http//gateway.zitech.com/gw/oauthentry/study.scene/1.0/getbysid?access_token=bb801ee6b9983c7f893473fd6a313ad2 &subject_id=This is afterclasstests run:4, Failures:4, errors:0, skipped:0, time elapsed:10.556 sec <<< failure!results:failed Tests:geturi (httpgettest) GetURI (httpgettest) GetURI (httpgettest) GetURI (HttpGetTest) tests run: 4, Failures:4, errors:0, skipped:0[INFO]------------------------------------------------------------------------[INFO] BUILD Failure[info]------------------------------------------------------------------------[INFO] Total time:26.159S[info] finished at:2016-05-07t16:59:59+08:00[INFO] Final memory:18m/176m[info]------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.5:test (default-test) on project Maven:there is test failures. [ERROR] [ERROR] Refer to/users/zhangbin/ideaprojects/httptest/target/surefire-reports forThe individual test results. [ERROR]→ [help 1][error] [ERROR] to see the full stack trace of the errors, re-run Maven with The-eSwitch. [ERROR] Re-run Maven using The-xSwitchTo enable full debug logging. [ERROR] [ERROR] For more information on the errors and possible solutions, please read the following articles:[error] [ Help1] http://cwiki.apache.org/confluence/display/maven/mojofailureexception

As you can see from the output, this interface is problematic.

3. Viewing HTML reports

There is a sentence in the output:

Refer To/users/zhangbin/ideaprojects/httptest/target/surefire-reports for the individual test results.

So our HTML report is in the target, Surefire-reports folder in the project folder, and I'm not attaching it anymore.

MacOS + idea configuration Maven + reportng

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.