当我检查步骤定义文件中的特定cucumber步骤时,如果条件为false,我希望使该特定测试用例停止并失败,然后继续下一个测试用例。
如果我必须使用FailureHandling.STOP_ON_FAILURE,如何编写这行代码?
@When("User enters the (.*) in the Login")
def user_enter_userid_in_the_Login(String uid) {
if (uid=='')
/** FAIL the TEST CASE **/
else
WebUI.setText(findTestObject('Object Repository/ORTC01/Page_/input_userid'), uid,
FailureHandling.STOP_ON_FAILURE)
WebUI.delay(5)
}发布于 2019-06-24 19:45:57
def user_enter_userid_in_the_Login(String uid) {
assert uid!='' //this will fail test if uid==''
...continue success code
}也可以提供错误消息
assert uid!='' : "the parameter 'uid' could not be empty"它大致对应于:
if(uid=='')throw new Exception("the parameter 'uid' could not be empty")https://stackoverflow.com/questions/56731520
复制相似问题