0

我有一个像身体一样的测试方法

{
    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
}

我怎样才能做到这一点?

4

3 回答 3

2

好吧,我不确定我是否理解,但是这样的事情会起作用

assertTrue("are my conditions true? {}",condition1 && condition2 && condition3) 
于 2013-04-24T08:04:03.933 回答
0

如果你已经到达这条线

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

那么你肯定知道你已经通过了所有的 assertTrue 语句。

于 2013-04-24T08:04:39.680 回答
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);
}
于 2013-04-24T08:05:10.993 回答