无法生成范围报告 - 尽管测试成功运行

时间:2017-03-23 12:44:57

标签: selenium webdriver testng

虽然我的测试成功运行,但我无法生成范围报告,低于我使用的代码和pom.xml 任何帮助表示赞赏。希望我对我的问题很清楚。请帮助解决这个问题:

import java.io.File; import java.util.Date;
import com.relevantcodes.extentreports.DisplayOrder;
import com.relevantcodes.extentreports.ExtentReports;

public class ExtentManager {
private static ExtentReports extent;

public static ExtentReports getInstance() {
    if (extent == null) {
        Date d=new Date();
        String fileName=d.toString().replace(":", "_").replace(" ", "_")+".html";
        extent = new ExtentReports("C:\\Users\\dilu316\\Documents"+fileName, true, DisplayOrder.NEWEST_FIRST);


        extent.loadConfig(new File(System.getProperty("user.dir")+"//ReportsConfig.xml"));
        // optional
        extent.addSystemInfo("Selenium Version", "2.53.0").addSystemInfo(
                "Environment", "QA");
    }
    return extent;
}
}
  

试验:

public class DummyTestB extends BaseTest{

ExtentReports rep = ExtentManager.getInstance();
ExtentTest test;
@Test
public void testB()
{
    test = rep.startTest("DummyTestB");
    test.log(LogStatus.INFO, "Starting the test test B");
    openBrowser("Mozilla");
    test.log(LogStatus.INFO, "Open the Browser");
    navigate("appurl");
    type("email_id","hara.mohapatra@gmail.com");
    click("button_xpath");  
    verifyTitle();
    reportFailure("title does not match");
    test.log(LogStatus.PASS, "Test B Passed");
}

@AfterMethod
public void quit()
 {
    rep.endTest(test);
    rep.flush();
 }
}
  

pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.selenium.core.ddf</groupId>
  <artifactId>DataDriven_Core_Framework</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>DataDriven Core Framework</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>2.53.0</version>
    <scope>test</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.11</version>
</dependency>



<!-- https://mvnrepository.com/artifact/com.relevantcodes/extentreports -->
<dependency>
    <groupId>com.relevantcodes</groupId>
    <artifactId>extentreports</artifactId>
    <version>2.41.2</version>
</dependency>


  </dependencies>
</project>

先谢谢。

1 个答案:

答案 0 :(得分:0)

public class BaseClass
{   
public static WebDriver driver; 
public static ExtentReports report;
public static ExtentTest test;

    @BeforeSuite
    public void InitIate() throws Exception
    {               
        report = new ExtentReports("YOURPATH", true);
        report.loadConfig("YOURPATH);           
    }
}   


public class TestSet1 extends BaseClass
{


@Test (priority=1)
public static void TestCase1()

{     

      test = report.startTest("TC desc");     
      // Blah Blah --your steps
      report.endTest(test);
      report.flush();
}           

}