[英]How do I skip one method to another when running the whole class?
我尝试在一堂课上测试多个测试,例如,我需要测试三个测试,
testA()
, testB()
, testC()
问题是,是否有任何代码可以跳过testA()
,如果在测试期间testA()
出错了,则可以继续执行testB()
?
我尝试了system.exit(1)
但是它将停止整个课程
您可以使用:
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
以进行异常处理
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.