我们正在建立一个Swift iOS项目,用fastlane构建,由SonarQube用SonarSwift插件进行分析。到目前为止,除了关于测试的信息之外,一切都能正常工作。
我们通过使用slather (Llvm)生成报告并将其重命名为Coverage.report并用路径填充sonar.swift.coverage.reportPath来添加代码覆盖率。
我们还生成*.junit文件并将它们输入sonar.junit.reportsPath。但这些似乎永远也不包括在内。我们只尝试路径./reports,并使用TEST-前缀和.xml结尾命名文件。我们还尝试了一个直接路径./reports/TEST-report.xml。
有人把这个弄到手了吗?如果是,怎么做?这是否得到了SonarQube的支持?
发布于 2021-04-03 11:57:23
根据https://community.sonarsource.com/t/number-of-unit-tests-is-zero/26104/6
JUnit报告只支持Java。
对于Swift,我们需要将报告转换为泛型类型
首先,对于 (https://gist.github.com/lucascorrea/80f3d57a7f97b2365ef39839eefe68a1)
xcrun llvm-cov show转换成声纳能识别的覆盖数据sonar.swift.coverage.reportPath配置为xcrun生成的报表路径sonar-scanner来提交覆盖率数据。 sh("xcodebuild -workspace ../brewdog.xcworkspace -scheme brewdog -sdk iphonesimulator -enableCodeCoverage YES -destination 'platform=iOS Simulator,name=iPhone 7,OS=11.3' GCC_GENERATE_TEST_COVERAGE_FILES=YES build test -derivedDataPath ../DerivedData")
sh("xcrun llvm-cov show -instr-profile=$(find ../DerivedData -iname 'Coverage.profdata') ../DerivedData/Build/Products/Debug-iphonesimulator/brewdog.app/brewdog > ../DerivedData/Coverage.report")其次,对于UnitTest (https://github.com/azohra/forsis),在完成此操作之后,您可以检查诸如单元测试计数、成功、失败、持续时间等信息(上面的链接中有一些图片)。
与此相同,您需要使用此工具将测试执行报告转换为泛型类型。
sonar.tests和sonar.testExecutionReportPaths中配置sonar-project.propertiessonar-scanner做完这两件事后,你可以在声纳网站的栏目中检查覆盖率和单元测试!
https://stackoverflow.com/questions/48881973
复制相似问题