要理解的一个重要概念是标签和配置文件之间存在差异。我也在将 Guard 与 Cucumber 一起使用,并且对继续使用默认配置文件并且我的 @wip(正在进行的工作)标签都没有被拾取感到沮丧。现在很明显为什么会这样。正如其他论坛中的一些人所说,我的默认配置文件过滤掉了@wip。
<%
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
base_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}"
std_opts = "#{base_opts} --strict --tags ~@wip"
wip_opts = base_opts
%>
default: --drb <%= std_opts %> features
wip: --drb <%= wip_opts %> --tags @wip:3 --wip features
rerun: --drb <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
"std_opts = "#{base_opts} --strict --tags ~@wip" wip在std_opts中被过滤掉
我想使用“wip”配置文件,其中包含用“@wip”标记的场景或功能!
wip: --drb --tags @wip:3 --wip features" 该数字表示要运行的最大场景数;' --wip' 表示 Cuc 预计测试将失败(因为我们正在处理它)
所以标签已经配置好了,我已经在我的 *.feature 文件中包含了“@wip”。简介呢?使用 Guard (Spork) 时,为了使用“wip”配置文件,需要对其进行配置。这说得通;电脑读不懂我的心!更新 Guardfile 以使用“wip”配置文件。
guard 'cucumber', :cli => "--drb -p wip", :all_on_start => false, :all_after_pass => false do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
guard 'cucumber', :cli => "--drb -p wip" '-p' 指定所需的配置文件
现在我的场景已成功被“wip”过滤。