Writing Test Results in Excel - Part 1
Pre-Req :
1. TestNG is required.
2. Download the Jar from here ExcelReportGenerator . Add this Jar into your project BuildPath.
Steps Below:
Step1 : Create a Package ‘ExcelResults’ under your Project.
Step2 : Create the testcases which you’d like to automate using TestNg. (by using @Test,BeforeTest,…….) as Shown.
public class Test
{
static WebDriver driver;
@Test(priority = 1)
public static void validatingDollarTest1() {
System.out.println(“this is validating the DollarTest1”);
}
@Test(priority = 2)
public static void ValidatingDollarTest2() {
System.out.println(“this is validating the DollarTest2”);
}
@Test(priority = 3)
public static void validatingDollarTest3() {
System.out.println(“this is validating the DollarTest3”);
}
}
Step3 : Create a testng.xml file under your Project as Shown.
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE suite SYSTEM “http://testng.org/testng-1.0.dtd”>
<suite name=”Random test suite” >
<test name=”EnterYourTestName”>
<classes>
<class name=”Test_98″/>
</classes>
</test>
</suite>
Now Run the testng.xml file.
Step 4 : Now Create a Class ‘ExcelGenerate’ and paste the following code.
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import com.raybiztech.commonexcelreport.ExcelReportGenerator;
public class ExcelGenerate
{
public static void main(String[]args) throws ParserConfigurationException, IOException, SAXException
{
ExcelReportGenerator exe= new ExcelReportGenerator();
exe.GenerateExcelReport(“YourTestName.xls”);
}
}
Step5 :Refresh the Package ‘ExcelResults’
Now you see the excelReport Generated. Its so simple huh !!!
*If you see the columns in the excel were disturbed please change the settings or Use the latest Version. I have made this using ‘Libre’.