Отчеты об экстентах, не генетические отчеты для всех тестов других классов

У меня есть 5 тестовых случаев в имени класса QaTest с аннотациями TestNG. когда я запускаю отчет по экстентам, он показывает результаты 5 тестов. Я правильно настроил XML-файл. здесь я вставляю код QaTest и отчет о степени. Пожалуйста, помогите

package satinder.com.satinder;
import java.io.File;

import org.testng.Assert;
import org.testng.ITestResult;
import org.testng.SkipException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
 
import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;
 
public class GenerateExtentReportTest{
 ExtentReports extent;
 ExtentTest logger;
 
 
 @BeforeTest
 public void startReport(){
  //ExtentReports(String filePath,Boolean replaceExisting) 
  //filepath - path of the file, in .htm or .html format - path where your report needs to generate. 
  //replaceExisting - Setting to overwrite (TRUE) the existing file or append to it
  //True (default): the file will be replaced with brand new markup, and all existing data will be lost. Use this option to create a brand new report
  //False: existing data will remain, new tests will be appended to the existing report. If the the supplied path does not exist, a new file will be created.
  extent = new ExtentReports (System.getProperty("user.dir") +"/test-output/STMExtentReport.html", true);
  //extent.addSystemInfo("Environment","Environment Name")
  extent
                .addSystemInfo("Host Name", "SoftwareTestingMaterial")
                .addSystemInfo("Environment", "Automation Testing")
                .addSystemInfo("User Name", "Rajkumar SM");
                //loading the external xml file (i.e., extent-config.xml) which was placed under the base directory
                //You could find the xml file below. Create xml file in your project and copy past the code mentioned below
                extent.loadConfig(new File(System.getProperty("user.dir")+"\\extent-config.xml"));
 }
  
 @Test
 public void passTest(){
  //extent.startTest("TestCaseName", "Description")
  //TestCaseName – Name of the test
  //Description – Description of the test
  //Starting test
  logger = extent.startTest("passTest");
  Assert.assertTrue(true);
  //To generate the log when the test case is passed
  logger.log(LogStatus.PASS, "Test Case Passed is passTest");
 }
 
 @Test
 public void failTest(){
  logger = extent.startTest("failTest");
  Assert.assertTrue(false);
  logger.log(LogStatus.PASS, "Test Case (failTest) Status is passed");
 }
 
 @Test
 public void skipTest(){
  logger = extent.startTest("skipTest");
  throw new SkipException("Skipping - This is not ready for testing ");
 }
 
 @AfterMethod
 public void getResult(ITestResult result){
  if(result.getStatus() == ITestResult.FAILURE){
   logger.log(LogStatus.FAIL, "Test Case Failed is "+result.getName());
   logger.log(LogStatus.FAIL, "Test Case Failed is "+result.getThrowable());
  }else if(result.getStatus() == ITestResult.SKIP){
   logger.log(LogStatus.SKIP, "Test Case Skipped is "+result.getName());
  }
  // ending test
  //endTest(logger) : It ends the current test and prepares to create HTML report
  extent.endTest(logger);
 }
 @AfterTest
 public void endReport(){
  // writing everything to document
  //flush() - to write or update test information to your report. 
                extent.flush();
                //Call close() at the very end of your session to clear all resources. 
                //If any of your test ended abruptly causing any side-affects (not all logs sent to ExtentReports, information missing), this method will ensure that the test is still appended to the report with a warning message.
                //You should call close() only once, at the very end (in @AfterSuite for example) as it closes the underlying stream. 
                //Once this method is called, calling any Extent method will throw an error.
                //close() - To close all the operation
                extent.close();
    }
}

и вот код для QaTest, который я хочу показать в отчетах о степени

package satinder.com.satinder;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

public class QaTest extends Bhandle {

@BeforeMethod
public void  browser1()
{ 
super.browser();
}
@Test
// Scenario is to login with invalid login  
public void loginwithinval() 
{  
   Login a=new Login(driver);
   a.login().click();
   a.username().sendKeys("qwer");
   a.password().sendKeys("123435");
   a.log().click();
   boolean sp=a.failed().isDisplayed();
   if (sp==sp) 
{
   System.out.println("The test case with invalid data is pass");
}
   else 
{  System.out.println("The test case with invalid data is failed");
}
   
}
@Test
//Scenario is to esignup 
public void esignup() throws InterruptedException  
{ 
   signup b= new signup(driver);
   b.sign().click();
   b.esignup().click();
   String u=driver.getTitle();
   b.efirstn().sendKeys("jhskwnhj");
   b.elastn().sendKeys("mjkdekt");
   b.eemail().sendKeys("nhldjkdh232@yahoo.com");
   b.eusern().sendKeys("sdljwdkv23");
   b.epass().sendKeys("losangeles1");
   b.erepass().sendKeys("losangeles1");
   b.esubmit().click();
   Thread.sleep(5000);
   String t=driver.getTitle();
   if (u.equals(t)) 
{
   System.out.println("the test case with signup data is falied ");
}
   else 
{
   System.out.println( "the test case with signup data is sucessfull and pass");
}
  
}

@Test
//Scenario is to login with valid credential 
public void login1() throws InterruptedException 
{ 
   
    Login a=new Login(driver);
    a.login().click();
    String u=driver.getTitle();
    a.username().sendKeys("sdljwdkv23");
    a.password().sendKeys("losangeles1");
    a.log().click();
    Thread.sleep(4000);
    String t=driver.getTitle();

    if (u.equals(t))  { 
     System.out.println("The log in unsuccessfull and test failed");
}
    else 
{ 
    System.out.println("The user logged in successfully and test pass");
}
   
}
@Test
//Scenario is to login with valid credential 
public void forgetpassword() throws InterruptedException
{ 
  
   Login a=new Login(driver);
   a.login().click();
   a.username().sendKeys("sdljwdkv23");
   a.password().sendKeys("losangele1");
   a.log().click();
   a.forget().click();
   String s=driver.getTitle();
   a.resetemailbox().sendKeys("nhldjkdh232@yahoo.com");
       a.sendpasswordbutton().click();
   Thread.sleep(4000);
   String w=driver.getTitle();
 
   if (w.equals(s)) 
{
   System.out.println(" This email is not registered and test is failed");
}
   else 
{  System.out.println("The password is reset and test pass");}

}
@Test
public void ifnotregistered() throws InterruptedException{ 

Login a=new Login(driver);
      a.login().click();
      a.notregistered().click();
      signup b= new signup(driver);
      //b.sign().click();
      b.esignup().click();
      String u=driver.getTitle();
      b.efirstn().sendKeys("jhaskwnhj");
      b.elastn().sendKeys("mjkadekt");
      b.eemail().sendKeys("anhldjkdh232@yahoo.com");
      b.eusern().sendKeys("sadlajwdkv23");
      b.epass().sendKeys("losangeles1");
      b.erepass().sendKeys("losangeles1");
      b.esubmit().click();
      Thread.sleep(5000);
      String t=driver.getTitle();
      if (u.equals(t)) 
      {
      System.out.println("the test case with signup data is falied ");
      }
      else 
      {
      System.out.println( "the test case with signup data is sucessfull and pass");
      }
      
      }
@AfterMethod
    public void close() 
{
driver.close(); 
}

}

1 ответ

Я думаю, что вы должны установить его в false здесь: экстент = новый ExtentReports (System.getProperty ("user.dir") + "/ test-output / STMExtentReport.html", false);

Другие вопросы по тегам