将带双引号字符串的参数传递到步骤

我定义了以下内容:Scenario


Scenario: test

    When test starts

    Then check data with '{"age":"18","gender":"male"}'

然后尝试传递到以下步骤:{"age":"18","gender":"male"}


func FeatureContext(s *godog.ScenarioContext) {

    s.Step(`^check data with "([^']*)"$`, checkDataWith)

}


func checkDataWith(data string) error {

    return godog.ErrPending

}

它说步骤没有推动,看起来没有正确传递,如何传递参数喜欢到步骤?{"age":"18","gender":"male"}{"age":"18","gender":"male"}


holdtom
浏览 93回答 1
1回答

凤凰求蛊

这个答案在另一种情况下帮助了我:https://stackoverflow.com/a/19257196在您的情况下,您可以尝试:func FeatureContext(s *godog.ScenarioContext) {    s.Step(`^check data with '(.*)'$`, checkDataWith)}func checkDataWith(data string) error {    return godog.ErrPending}因此,数据将按照步骤描述中的方式传递到方案:{"age":"18","gender":"male"}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Go