2017-03-23 4 views
1

私のテストは正常に実行されましたが、私は使用したコードと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","[email protected]"); 
    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> 

感謝。

答えて

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(); 
}   

} 
+0

なしまだ同じ、何の報告書は、基本クラス内のpublic staticとして –

+0

しようと宣言しExtentReportsとExtentTestを生成しないとDummyTestBにそのクラスを拡張してしまった...私は現在、新しいレポート/テスト・オブジェクトが代わりに作成されていると思います既に存在しているものの、 – FreakTester

+0

私は問題がtestngまたはextentreportsのバージョンにあると思うが、私は上記を同じように試した。 –

関連する問題