2016-04-13 26 views
0

Benim Junit Test işlevinin try-catch bloğu var. Yakalama bloğunda ExtentReport'ta günlük hatası için bir istisna yakalarım. Ayrıca, Apache ant 'junitreport' dan Junit raporu oluşturuyorum. Sorunum, benim catch bloğumdaki istisnayı yakaladığımdan, üretilen Junit hatası hata göstermiyor. Nihai sonuç için istisnayı kaydetmek için istisna (veya başka bir yol) nasıl yazılır.Junit test işlevi catch bloğundan istisna nasıl atılır?

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

cevap

0

yerine istisna sarılması bunu rethrow olabilir: Burada

kodudur.

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

Yeniden atanan özel durumu denedim. Hata olarak hala kayıt olmayacaktır. – vikas

İlgili konular