频道
bg

Sonarqube Coverage

coding二月 01, 20211mins
QA

Coverage ReportH2

对于Java项目使用Jacoco

对于Javascript项目使用Jest

Sonarqube覆盖率有时候会把测试文件本身也算进去,这些文件在覆盖报告中是没有的,会导致Sonarqube服务器认为这些文件的覆盖率是0%

设置忽略这些文件

jsx

sonar.coverage.exclusions=**/*.test.*

JestH2

Jest支持四种覆盖报告文件["json", "lcov", "text", "clover"]

jsx

npm run test --coverage

如果定了threshold并且不符合threshold,会运行失败,

json

"jest": {
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": 90
}
}
}

临时关闭threshold

jsx

npm run test --coverage --coverageThreshold '{}'

评论


新的评论

匹配您的Gravatar头像

Joen Yu

@2022 JoenYu, all rights reserved. Made with love.