dongpao9165 2019-01-02 11:52
浏览 7
已采纳

停止godog解析方案大纲示例数据表行

I am not sure it this is intended to be so, but I am confused by the behavior.

When I have the following Scenario Outline:

Scenario Outline: outline1
Given url
And query parameters <query_params>
When method
Then status is
Examples:
| method | endpoint   | query_params | status |
| GET    | /endpoint1 | ?a=1&b=1     | 200    |
| GET    | /endpoint1 | ?a=1&b=1&c=3 | 200    |

I see the following snippet generated.

func FeatureContext(s *godog.Suite) {
s.Step(^method GET$, methodGET)
s.Step(^query parameters \?a=(\d+)&b=(\d+)$, queryParametersAB)
s.Step(^query parameters \?a=(\d+)&b=(\d+)&c=(\d+)$, queryParametersABC)
}

As you can see 2 lines of "query parameters" produces 2 different functions. Why is godog parsing this text? This is a little different from cucumber gherkin parsing.

One side effect of this is that if I have 100 lines in the data table, I am forced to implement all of them.

Is there a way I can ask godog to not do this parsing?

  • 写回答

1条回答 默认 最新

  • dongzhu0327 2019-01-08 17:53
    关注

    The solution to the problem is to use double quotes around as given below.

    Scenario Outline: outline1
    Given url
    And query parameters "<query_params>"
    When method
    Then status is
    Examples:
    | method | endpoint   | query_params | status |
    | GET    | /endpoint1 | ?a=1&b=1     | 200    |
    | GET    | /endpoint1 | ?a=1&b=1&c=3 | 200    |
    

    Then the following will be generated:

    s.Step(`^query parameters "([^"]*)"$`, queryParameters)
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度