繁体   English   中英

在运行整个类时,如何跳过一个方法到另一个方法?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM