2013-04-24 37 views
0

我有一個測試方法像身體一樣如何查找是否所有assertTrue通過或任何人失敗?

{ 
    assertTrue("Login failed", somecondition); 
    assertTrue("Page not browsing", somecondition); 
    assertTrue("Button not found", somecondition); 
    //here I want to found whether any assertTrue failed or all are passed 
} 

我怎樣才能做到這一點?

+2

什麼這工作已經 - 如果任何斷言失敗,你會得到一個' AssertionError'。否則,你不會。 – 2013-04-24 08:07:52

回答

2

好了,我不知道我的理解,但這樣的事情應當制定

assertTrue("are my conditions true? {}",condition1 && condition2 && condition3) 
0

如果你已經到達線

//here I want to found whether any assertTrue failed or all are passed 

,那麼你肯定知道你已經通過了所有你的assertTrue陳述。

0

你都必須使用「assertTrue」的方法登錄JUnit的報告中的條目,並使用自己的變量來計算出你想要

{ 
    allPassed = True; 

    assertTrue("Login failed", somecondition); 
    allPassed = allPassed && somecondition; 

    assertTrue("Page not browsing", somecondition); 
    allPassed = allPassed && somecondition; 

    // ... 

    assertTrue("All tests succeeded", allPassed); 
} 
相關問題