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