【问题标题】:Escaping characters in cucumber step definition黄瓜步骤定义中的转义字符
【发布时间】:2020-12-29 05:35:46
【问题描述】:

我已使用以下步骤 def 从给定的弹出模式中捕获错误消息

Then warning "Invalid file. File name should be "Users.xml" " should be given to user

在这种情况下,我想在给定的字符串中包含“User.xml”

@Then("^warning \"([^\"]*)\" should be given to user

但这不会转义“。我如何转义这个”字符以匹配确切的字符串

【问题讨论】:

    标签: cucumber escaping bdd


    【解决方案1】:

    你需要改变

    @Then("^warning \"([^\"]*)\" should be given to user

    @Then("^warning \"(.*?)\" should be given to user$"

    [^"]* 匹配除引号之外的所有内容

    .*? 将匹配所有内容(包括引号)

    更多信息请见here

    您也可以使用多行字符串来执行上述链接中的说明

    另请参阅video tutorial 以在您的参数中包含字符串

    【讨论】:

    • 我很高兴,我可以帮忙
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-10
    • 1970-01-01
    相关资源
    最近更新 更多