首页 > 解决方案 > 运行整个课程时如何跳过一种方法到另一种方法?

问题描述

我尝试在一个类下测试几个测试,例如我需要测试三个测试
testA(),<code>testB()、<code>testC()

问题是如果在测试期间出错,我可以跳过testA()并继续执行任何代码吗?testB()testA()

我试过system.exit(1)了,但它会阻止整个班级

标签: javaandroidui-automation

解决方案


您可以使用:

try{
   //if there is any error here, it will skip and will be caught by the catch block
   testA()
} catch (Exception e){
   //handle your exception here
   testB()    
}

签出:Try-catch用于异常处理


推荐阅读