swift - 在 Fastlane 中重新启动失败的 XCTest
问题描述
我正在尝试重新启动通过 Fastlane 失败的测试。
这是我正在使用的脚本,但没有取得多大成功。不工作的部分是 find_failed_tests。由于某种原因,失败的测试不在 junit 报告中。
@test_retries = 3
TARGET_DEVICES = ["iPad Pro (9.7-inch)"]
lane :testRetry do
testNames = ["Example_UITests/SearchForm_TestA", "Example_UITests/SearchForm_TestB"]
UI.message("Testing only tests: #{testNames}")
begin
scan(
scheme: "Example",
devices: TARGET_DEVICES,
output_types: 'junit',
fail_build: false,
only_testing: testNames,
clean: true
)
rescue
while @test_retries > 0
failed_tests = find_failed_tests
UI.message("Retrying failed tests: #{failed_tests}")
break if failed_tests.empty?
@test_retries -= 1
scan(
scheme: "Example",
devices: TARGET_DEVICES,
output_types: 'junit',
fail_build: @test_retries.zero?,
only_testing: failed_tests,
clean: true
)
end
end
end
def find_failed_tests
report = File.open('test_output/report.junit') { |f| Nokogiri::XML(f) }
suite_name = report.xpath('testsuites/@name').to_s.split('.')[0]
test_cases = report.xpath('//testcase')
only_testing = []
test_cases.each do |test_case|
next if test_case.xpath('failure').empty?
test_class = test_case.xpath('@classname').to_s.split('.')[1]
test_name = test_case.xpath('@name')
only_testing << "#{suite_name}/#{test_class}/#{test_name}"
end
only_testing.join(',')
end
我遇到的问题是junit中没有报告失败的测试。report.xml 只显示通过的测试。
解决方案
推荐阅读
- java - 如何编写一个函数来检查给定的二叉搜索树是否包含给定的值?
- javascript - 逗号分隔 React-Table 中的数组?
- javascript - 如何避免在网页返回时通过 JS 触发重复的 PubNub 通知
- c# - 远程服务器返回错误:(553) File name not allowed [C#] [FTP]
- c - 当给定 3 的位掩码时,为什么 printf() 打印 21 而不是 11?
- javascript - 使用 javaScript 重新加载特定的文本框/选择选项
- python - 将空白视频添加到音频的 Python 脚本(多个)
- matlab - 使用值中的空格逐行导入 ASCII 制表符分隔
- django - Django-allauth 没有在自定义 SignupForm 上保存附加字段
- javascript - 我如何将身份验证错误从节点 js 发送到我的 html 客户端页面?