1

I am working on application that requires two browsers at once so my code launches two browsers at once Chrome and FF, perform some test cases on chrome and some on FF parallel - when I execute my code thru execution files, It executes fine and generate the extent reports for all suits separately. Now I am trying to execute my project thru testng.xml(see below) that contains more than one suit, I seeing issues with that as follows; 1. Each test case displays twice under logs but once in extent report 2. One Extent report generated for two suits since I want to generate one report per suit

testng.xml

    <test name="Some Workflow Tests 1"  thread-count="5" parallel="none">
        <classes>
            <class name="Master.Websites"/>
        </classes>
    </test>


    <test name="Some Workflow Tests 2"  thread-count="5" parallel="none">
        <classes>
            <class name="Master.CompanyStore"/>
        </classes>
    </test>

Please see extent report code below;

@AfterMethod

    public void getResult(ITestResult result ) throws IOException, InterruptedException{
    /*
         System.out.println("Get Status "+ result.getStatus());
         System.out.println("Get Method with className "+ result.getMethod());
         System.out.println("Get TC Name "+ result.getName());
         System.out.println("Get test calsss Name "+ result.getTestClass());
         System.out.println("Get Test Name"+ result.getTestName());
         System.out.println("Get Method Name"+ result.isSuccess());
    */
         test = extent.createTest(result.getName());

        if(result.getStatus()==ITestResult.SUCCESS){
            test.log(Status.PASS, result.getMethod().getDescription());
            test.log(Status.PASS, MarkupHelper.createLabel(result.getName() + " Test Case is Passed", ExtentColor.GREEN));
            test.log(Status.PASS, " Please see attached screenshot");
            String screenshotPath = HelpingFunction.capture(result.getName());
            test.addScreenCaptureFromPath(screenshotPath);

            extent.flush();
            }


        if(result.getStatus()==ITestResult.FAILURE){

            test.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + "Test Case is Failed due to Below Issue", ExtentColor.RED));
    /*
     * String screenshotPath = HelpingFunction.capture(result.getName());
     * test.addScreenCaptureFromPath(screenshotPath);
     */
            test.fail(result.getThrowable());
            extent.flush();
            }


        if(result.getStatus()==ITestResult.SKIP){
            System.out.print("Test cases is skipped");
             test.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + "Test Case is SKIPPED", ExtentColor.YELLOW));
             test.skip(result.getThrowable());
            }                       

     }


        @AfterTest
        public void endReport(){
        driver.close();
        //extent.flush();

        //driver.get(System.getProperty("user.dir")+"/Reports/"+Suite);
        }

below code for extent report configuration;

public static void Property(String Suite, String RName) throws InterruptedException, AWTException, IOException{

                try {
                    ExtentHtmlReporter htmlReporter;
                    htmlReporter = new ExtentHtmlReporter("./Reports/"+Suite);

                    extent = new ExtentReports();
                    extent.attachReporter(htmlReporter);
                    extent.setSystemInfo("HostName", "Iftikhar");
                    extent.setSystemInfo("Environment", "QA");
                    extent.setSystemInfo("UserName", "Muhammad Iftikhar");
                    extent.setSystemInfo("URL", envirnment);
            //      extent.setReportUsesManualConfiguration(true);
                    htmlReporter.config().setDocumentTitle("Automation Testing Report");
                    htmlReporter.config().setReportName("Sep Report");
                    htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);
                    htmlReporter.config().setTheme(Theme.DARK);
                    htmlReporter.getStartTime();
                    htmlReporter.getEndTime();

                } 
                catch (IndexOutOfBoundsException e) {
                    System.err.println("IndexOutOfBoundsException: " + e.getMessage());
                    }

                }

Please see below screenshots for logs and extent report

This is how I am seeing the test cases

This is how I am seeing the extent report

I am working on this issue for many days but still no success. Request to all for help. Thank you.

Saba Malik
  • 281
  • 3
  • 6
  • 12

0 Answers0