2013-03-01 91 views
0

假設我有10個測試用例,其中第二個測試用例發生了Exception。發生後剩下的測試不會開始。 Exception發生後如何保持跑步測試?如何在Exception發生後繼續運行測試?

+0

當一個測試拋出一個異常,它試圖運行其他測試,所以我不知道你是如何運行到這種情況? – 2013-03-02 14:33:29

回答

0

在catch塊中添加其他測試用例。
假設異常會在第二個測試用例中出現,那麼您可以在該catch塊中添加其餘的測試用例。
有些時候我們需要在獲得異常或緩存異常之後使用某些功能。
你可以使用Catch塊來做到這一點。

try{ 
testcase1 
testcase2 
. 
. 
. 
. 
testcase10 
}  
catch(Exception e) 
{ 
    if(testcase1.isExecute()||blaa || blaa) 
    { 
     //you have something to check here which testcases have exception or which testcase is executed 
    run your rest of test cases. 
    testcase7 
    . 
    . 
    testcase10 
} 

此代碼可能對您有所幫助。這只是邏輯,你需要做的實現..

相關問題