gpt4 book ai didi

tags - 使用 cucumber 从特征文件中获取标签

转载 作者:行者123 更新时间:2023-12-04 02:29:35 27 4
gpt4 key购买 nike

是否有命令行选项可以列出您的 Cucumber 测试套件中的所有标签?

例如,我想要这样的东西:
cucumber --show-tags foo.feature

那会给我类似的东西:
@ci
@development
@regression
@wip

我尝试过的语法是“cucumber -f tag_cloud foo.feature”
它给了我“无法加载 tag_cloud(load_error)”

我只是想知道如何准确地做到这一点。

我需要额外安装任何api吗??或者情况如何?

请帮助我

最佳答案

相信--show-tags选项已弃用。相反,您必须使用自定义格式化程序。

Nat Ritmeyer 为这项任务提供了一个很好的自定义格式化程序 - https://gist.github.com/natritmeyer/2995205 .

1) 将以下内容复制到“features/support”目录中的“list_tags.rb”文件中:

=begin

Copyright (c) 2012, Nathaniel Ritmeyer
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

3. Neither the name Nathaniel Ritmeyer nor the names of contributors to
this software may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

=end


require 'cucumber/formatter/console'
require 'cucumber/formatter/io'

module Cucumber
module Formatter
class ListTags
include Io
include Console

def initialize(step_mother, path_or_io, options)
@io = ensure_io(path_or_io, "list_tags")
@all_tags = []
end

def tag_name(tag_name)
@all_tags << tag_name
end

def after_features(features)
@all_tags.uniq.sort.each {|tag| @io.puts tag}
end
end
end
end

2)然后运行 cucumber 使用:
cucumber -d -f Cucumber::Formatter::ListTags

这会(干)运行您的功能并使用自定义格式化程序格式化结果。结果是标签列表。例如:
@feature1
@feature2
@scenario1
@smoke1
@smoke2

关于tags - 使用 cucumber 从特征文件中获取标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18442904/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com