Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class simpletest3 {
- public ExtentReports rep=ExtentManager.getInstance();
- public ExtentTest test;
- public Keywords app;
- public String testName;
- @Test(dataProvider="dta")
- public void mytest(String uname,String pwd){
- testName = "SamTest";
- test = rep.createTest(testName);
- System.out.println("Inside"+uname+pwd);
- System.out.println(Thread.currentThread().getId());
- test.info("Executing test Case with the data:: username ="+uname+" and the pwd = "+pwd);
- }
- @DataProvider(parallel=false)
- public Object[][] dta(){
- return new Object[][] { { "testuser_1", "Test@123" },
- { "testuser_2", "Test@456" },
- { "testuser_3", "Test@458" },
- };
- }
- @AfterMethod
- public void getResult(ITestResult result)
- {
- if(result.getStatus() == ITestResult.FAILURE)
- {
- test.log(Status.FAIL, MarkupHelper.createLabel(result.getName()+" Test case FAILED due to below issues:", ExtentColor.RED));
- test.fail(result.getThrowable());
- }
- else if(result.getStatus() == ITestResult.SUCCESS)
- {
- test.log(Status.PASS, MarkupHelper.createLabel(result.getName()+" Test Case PASSED", ExtentColor.GREEN));
- }
- else
- {
- test.log(Status.SKIP, MarkupHelper.createLabel(result.getName()+" Test Case SKIPPED", ExtentColor.ORANGE));
- test.skip(result.getThrowable());
- }
- }
- @AfterTest
- public void tearDown()
- {
- rep.flush();
- }`
- public static ExtentReports getInstance(){
- Date d=new Date();
- String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
- ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(Constants.REPORT_PATH+fileName);
- System.out.println(Constants.REPORT_PATH+fileName);
- //extent = new ExtentReports(Constants.REPORT_PATH+fileName, true, DisplayOrder.NEWEST_FIRST);
- extent = new ExtentReports();
- extent.attachReporter(htmlReporter);
- return extent;
- }
Add Comment
Please, Sign In to add comment