2016-04-13 14 views
0

My Junit Test機能にtry-catchブロックがあります。 catchブロックで、ExtentReportのログにエラーが発生しました。 また、Apache ant 'junitreport'からJunitレポートを生成しています。 私のキャッチブロックで例外をキャッチしているので、Junit の結果はエラーを表示しません。 Junit結果の例外を登録するための例外(または他の方法)をスローする方法。Junitテスト関数catchブロックから例外をスローする方法は?

try { 
    //Test code 
    } catch (Exception e) { 
      extentTest.log(LogStatus.ERROR, "Exception in clicking "); //For ExtentREport Logging 
      e.printStackTrace(); 
      throw(new Exception(e.getMessage(), e)); //Expected Junit to capture error, but it is not happening 
    } 

Screen shot of both Extent Report and Junit report of the same test

答えて

0

の代わりに、あなたがそれを再スロー可能性の例外をラップ:ここ

はコードです。

try { 
    //Test code 
} catch (Exception e) { 
    extentTest.log(LogStatus.ERROR, "Exception in clicking "); //For ExtentREport Logging 
    e.printStackTrace(); 
    throw e; 
} 
+0

私は再スロー例外を試みました。それでもエラーとして登録されません。 – vikas

関連する問題