是的,可以在Cucumber with Ruby中实现一个功能,输出场景运行的百分比,以及每个场景的沿着。为了实现这一点,您可以使用Cucumber的钩子和Runner类来跟踪场景的进度。
# Define global variables to track progress
$total_scenarios = 0
$current_scenario = 0
BeforeAll do
# Calculate total number of scenarios
# This might vary depending on how your test suite is structured
$total_scenarios = Cucumber::Core::Test::Runner.scenarios.count
end
Before do |scenario|
# Increment the current scenario count
$current_scenario += 1
# Calculate the progress
progress_percent = ($current_scenario.to_f / $total_scenarios.to_f * 100).round(2)
# Output the progress
puts "Scenario #{$current_scenario} of #{$total_scenarios} (#{progress_percent}%)"
puts "Running Scenario: #{scenario.name}"
end
AfterAll do
# Any finalization if needed
end
1条答案
按热度按时间lzfw57am1#
是的,可以在Cucumber with Ruby中实现一个功能,输出场景运行的百分比,以及每个场景的沿着。为了实现这一点,您可以使用Cucumber的钩子和Runner类来跟踪场景的进度。
字符串