【问题标题】:Handling fail cases in Robotium在 Robotium 中处理失败案例
【发布时间】:2014-07-18 20:54:45
【问题描述】:

如果一个测试用例失败,我喜欢执行我的 robotsium 下一个测试用例。我尝试过使用 try-catch、if-else 等,但没有按我预期的那样工作。如果它无法处理任何事情,它就会失败。 所以我想知道 1)robotium是否可以处理异常? 2)如果有可能怎么办? 3)如果不能用robotium,是否可以使用robotium+java或robotium+junit,像这样处理这种情况?

请帮助我。我对此进行了很多搜索,然后才发布此问题。所以请提供一些建议或解决方案

非常感谢。

【问题讨论】:

标签: robotium


【解决方案1】:

是的,Robotium 可以使用 try-catch 块处理异常:

    try{
        // The attempted code.
    } catch (SomeExceptionClass e){
        // Do something on an exception or just percolate:
        throw e;
    }

还有一个example SO post 展示了如何在不需要try-catch 的情况下也抛出一个新的Exception。要点:

        if (bundle != null) {
            // The attempted code...
        } else {
            throw new Exception("Here's my error message!");
        }

事实上,如果您想了解更多信息,Google Group 会讨论 Robotium here 中的异常处理。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-24
    • 1970-01-01
    • 2013-12-08
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    相关资源
    最近更新 更多