"Test Report"-testng HTML and XML reports

Source: Internet
Author: User
Tags testng

TestNG is part of some of the predefined listener libraries. By default, these listeners join any test execution and produce different HTML and XML reports for any test execution. The report produces a folder named Testoutput by default and can be changed to any other folder by configuration. These reports contain some specific reports of HTML and XML testng.

Create a test case class

Create a Java class named Sampletest.java in C + + > Testng_workspace

ImportOrg.Testng.Assert;ImportOrg.Testng.Annotations.Test;Public Class Sampletest { @Test Public voidTestmethodone(){ Assert.Asserttrue(True); } @Test Public voidTestmethodtwo () {assert. Asserttruefalse}  @Test  ( Dependsonmethods={ "testmethodtwo" })  Span class= "KWD" >public void Testmethodthree  () { assert. Asserttruetrue}}          /span>                

The above test class contains three test methods, which will pass at the time of execution Testmethodone and Testmethodthree, Instead of Testmethodtwo by a false Boolean value of the Assert.asserttrue method, it is used in the test to fail the truth condition.

Create Testng.xml

Create a testng.xml in C: \ > Testng_workspace to execute Test cases

<?XML version="1.0"Encoding= "UTF-8" ?><suite  name= "simple Html-xml Suite" > <test name< Span class= "pun" >= "simple html-xml test" > <classes> <classname= "sampletest"  / > </classes> </test></SUITE>           

Compile using the Javac Sampletest class.

C:\testng_workspace>javac Sampletest.java

Now, run Testng.xml.

C:\TESTNG_WORKSPACE>JAVA-CP "C:\TestNG_WORKSPACE" Org.testng.TestNG testng.xml

Verify the output.

===============================================simple html-xml suitetotal tests Run:3, failures:1, skips:1========== =====================================

Now, go to the C:\TestNG_WORKSPACE\test-output directory. The default Web browser opens index.html. You will see the following HTML report content as follows:

Now open C:\TestNG_WORKSPACE\test-output\testing-results.xml The default XML editor on your system, you will see the following results in the XML file:

TestNG generates multiple reports by default as part of their test execution. These reports mainly include TestNG HTML reports, TestNG e-mail sent reports, TestNG reports XML and JUnit report XML files. These files can be found under the Output Report folder (in this case, the test output). This default report generates a property that runs tests while you can disable the value by setting the value of Defaultlisteners to false. This property can be used at the same time, such as Ant or Maven build tools.

Test report-testng HTML and XML reports

Related Article

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.