2016-04-13 6 views
0

Meine Junit-Testfunktion hat einen try-catch-Block. In catch block erhalte ich Ausnahme, um Fehler in ExtentReport zu protokollieren. Außerdem erzeuge ich einen Junit-Bericht von Apache ant 'junitreport'. Mein Problem ist, da ich die Ausnahme in meinem catch-Block abfangen, zeigt das Junit Ergebnis keinen Fehler angezeigt. Wie man Exception (oder eine andere Weise) ausgibt, um die Ausnahme für Junit-Ergebnis auch zu registrieren. HierWie wird die Ausnahme vom Junit-Testfunktions-Catch-Block ausgelöst?

ist der Code:

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

Antwort

0

Statt die Ausnahme Umwickeln Sie könnte es erneut auslösen.

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

Ich hatte versucht, Ausnahme neu zu werfen. Es wird immer noch nicht als Fehler registriert. – vikas

Verwandte Themen