2016-06-23 5 views
1

私はjavaを使用してselenium-webdriverを使用しています。私はtestNGを使用しています。実行後、私はデフォルトのレポートを取得します。しかし、スイートを再実行すると、以前の結果が上書きされます。前回のテスト出力結果を上書きせずにtestngレポートを生成しますか?

以前のテスト出力結果を上書きせずにtestngレポートを生成できますか?

ビルドツールが必要ですか?はいの場合はどのようにMavenでそれを行うには?

答えて

0

はい、以前に上書きしなくてもレポートを生成できます。

これを達成するには、レポート出力ディレクトリをパラメータ化する必要があります。

私は純粋TestNGのでそれを行う方法を、知りませんが、Mavenの-確実な-プラグインでそれは非常に簡単です:

<plugins> 
    <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <configuration> 
      <suiteXmlFiles> 
       <suiteXmlFile>testng-suite.xml</suiteXmlFile> 
      </suiteXmlFiles> 
      <reportsDirectory>report_${maven.build.timestamp}</reportsDirectory> 
     </configuration> 
    </plugin> 
</plugins> 

これは、ユニークな接尾辞として現在のタイムスタンプを使用して、各実行用に別のディレクトリを作成します。

0

あなたはレポートを格納しているディレクトリへのパスを持っているし、将来の参照用のレポートを超えて維持したい場合は、時間は、レポートの名前をスタンプすることができます

Calendar cal = Calendar.getInstance(); 
    Date time=cal.getTime(); 
    String timestamp=time.toString(); 
    String systime=timestamp.replace(":", "-"); 
    int year = cal.get(Calendar.YEAR); 
    int month = (cal.get(Calendar.MONTH)+1); 
    int day = cal.get(Calendar.DAY_OF_MONTH); 



    public void generateReport (List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) { 
    extent = new ExtentReports("C:\\XAMPP\\htdocs\\TestReports\\TestReport" + " " + systime + "_" + Constants.U360_VERSION +".html"); 
関連する問題