2017-01-11 9 views
0

エクステントレポートのバージョンを示してい.javaエクステントレポートには、最後のテストケース結果

package framewrk; 

import org.testng.annotations.AfterClass; 
import org.testng.annotations.BeforeClass; 
import org.testng.annotations.Test; 
import com.aventstack.extentreports.ExtentReports; 
import com.aventstack.extentreports.ExtentTest; 
import com.aventstack.extentreports.Status; 

public class TC1 { 
    static ExtentReports extent; 
    static ExtentTest test; 

    @BeforeClass 
    public void setup(){ 
     extent = ExtentManager.GetExtent(); 
    } 

    @Test 
    public void OpenUT(){ 
     test = extent.createTest("Testing how fail works"); 
     test.log(Status.INFO, "fail check started"); 
     test.fail("Test fail"); 
    } 

    @AfterClass 
    public void tear() 
    { 
     extent.flush(); 
    } 
} 

TC2.java

package framewrk; 

import org.testng.annotations.AfterClass; 
import org.testng.annotations.BeforeClass; 
import org.testng.annotations.Test; 
import com.aventstack.extentreports.ExtentReports; 
import com.aventstack.extentreports.ExtentTest; 
import com.aventstack.extentreports.Status; 

public class TC2 { 
    static ExtentReports extent; 
    static ExtentTest test; 

    @BeforeClass 
    public void setup(){ 
    extent = ExtentManager.GetExtent(); 
    } 

    @Test 
    public void OpenUT(){ 
     test = extent.createTest("Testing how pass works"); 
     test.log(Status.INFO, "pass check started"); 
     test.pass("Passed"); 
    } 

    @AfterClass 
    public void tear() 
    { 
     extent.flush(); 
    } 
} 

これらの2つのテストケースを実行すると、最後のテストケース結果しか得られません。第1のテストケース結果では、エクステントレポートには表示されません。 エクステント・レポート3.0にappendパラメータがないことに注意してください。 エクステントレポートのすべてのテストケース結果を取得するにはどうすればよいですか?上記のアプローチでは

Only last test case result shown, how to get all tests results

答えて

1

は、各クラスの新しいエクステントレポートを作成しています。そのため、最新のテスト結果のみを取得しています。

TC1クラスとTC2クラスの両方に共通のスーパークラスを作成できます。スーパークラスでは、@AfterClass関数と@BeforeClass関数を作成できます。そうすればうまくいくはずです。

希望すると助かります!

関連する問題