0

I'm facing issue with regard to adding child tests to parent.

My requirement is: I want to have a parent label (for e.g. Login) with expand ('+') icon, when I click on '+' icon, I should be able to all login tests (which would be child tests added to Login label

the code:

package Rapport;


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;

import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;

import test1.TimeReport;




@Listeners(TimeReport.class)
public class Test001 {

    private ExtentReports reporter =  SimpleReportFactory.getReporter();
    ExtentTest testReporter ;
    //ExtentReports extent;

    ExtentTest parent;
     public void TearDown()
        {
            parent.appendChild(testReporter);
        }
 public Test001() 
 {
     parent = reporter.startTest("Test001");
 }

    @Test
    public void simpleTest004()
    {
        testReporter = reporter.startTest("simpleTest004", "This is a simple simpleTest004");
        testReporter.log(LogStatus.INFO, "Starting test simpleTest004");
        int a = 100;
        int b = 30;

        testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
        Assert.assertTrue(true);
    //  testReporter.log(LogStatus.FA, "Loading the value of b to " + b);
        reporter.endTest(testReporter);

    }




    @Test
    public void simpleTest003()
    {
        testReporter = reporter.startTest("simpleTest003", "This is a simple simpleTest003");
        testReporter.log(LogStatus.INFO, "Starting test simpleTest003");
        int a = 100;
        int b = 30;

        testReporter.log(LogStatus.INFO, "Loading the value of a to " + a);
        Assert.assertTrue(true);
    //  testReporter.log(LogStatus.FA, "Loading the value of b to " + b);
        reporter.endTest(testReporter);

    }


    @AfterMethod
    public void tearDown(ITestResult result) {
        if (result.getStatus() == ITestResult.FAILURE) {
            testReporter.log(LogStatus.FAIL, "<pre>" + result.getThrowable().getMessage() + "</pre>");
        }        
    }



    @AfterSuite
    public void afterSuite()
    {
        reporter.close();
    }


}

Any assistance would be greatly appreciated!

joe
  • 31
  • 8

0 Answers0