为什么行号附加到黄瓜命令行用户变量?

Why is the line number appended to a cucumber command line user variable?

这是我的黄瓜命令

cucumber features/xxx.feature -l 409 ENVIRONMENT=LOCAL BROWSER=true

当我做puts ENV['ENVIRONMENT']时,值是LOCAL:409ENV['BROWSER'].

也是一样

因此,我的脚本失败了,因为这不是预期的追加。

问题出在 CLI 参数的解析中。自 original implementation of the lines option. You can see the following in the Cucumber::Cli::Options on Line 142-144:

以来似乎一直如此
@args.map! { |a| "#{a}:#{@options[:lines]}" } if @options[:lines]

extract_environment_variables

map! 语句将行号添加到每个剩余参数,其中包括:

  1. 指定的特征文件,features/xxx.feature(好)
  2. 每个环境变量(坏)

extract_environment_variables 需要在 map! 之前,这样映射时环境变量就不会包含在 @args 中。

除了等待我在 Issue 1064 中打开的 Cucumber 中修复错误外,您唯一的选择似乎是使用 FILE:LINE 语法而不是 -l 选项:

cucumber features/xxx.feature:409 ENVIRONMENT=LOCAL BROWSER=true