gpt4 book ai didi

javascript - 将 Angular 单元测试报告导入 Sonarqube

转载 作者:行者123 更新时间:2023-12-03 02:11:37 32 4
gpt4 key购买 nike

上下文

在使用 karma 和 jasmine 进行单元测试的 Angular5 项目中,我使用 karma-sonarqube-unit-reporter 为我的单元测试生成此报告文件。

<testExecutions version="1">
<file path="src/app/app.component.spec.ts">
<testCase name="app/app.component.spec.ts should create the app" duration="314"/>
<testCase name="app/app.component.spec.ts should have as title 'Projet de test Angular5'" duration="104"/>
<testCase name="src/app/app.component.spec.ts should render title in a h1 tag" duration="114"/>
</file>
<file path="src/app/client-add/client-add.component.spec.ts">
<testCase name="client-add/client-add.component.spec.ts should create" duration="107"/>
</file>
<file path="app/client.service.spec">
<testCase name="app/client.service.spec #getClients should return an Observable&lt;Client[]>" duration="38"/>
</file>
<file path="src/app/message.service">
<testCase name="app/message.service should be created" duration="35"/>
</file>
</testExecutions>

但是当我将其导入 Sonarqube (v6.7)(通过 Jenkins)时,我得到以下内容

INFO: Sensor Generic Test Executions Report
WARN: Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.
INFO: Parsing C:\Users\adminpp\.jenkins\workspace\ELIS JustElis Beta WEB\reports\ut_report.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 4 unknown files, including:
src/app/app.component.spec.ts
src/app/client-add/client-add.component.spec.ts
src/app/client.service.spec
src/app/message.service
INFO: Sensor Generic Test Executions Report (done) | time=110ms

这是我的 Sonar 属性,用于排除和包含源和测试代码。

sonar.sourceEncoding=UTF-8
sonar.sources=.
sonar.exclusions=**/node_modules/**
sonar.test.inclusions = **/*.spec.ts
sonar.import_unkown_files=true
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=reports/ut_report.xml

我检查了一下,发现我的 *.spec.ts 文件位于它们应该在的位置。

问题

为什么 Sonarqube 找不到我的文件?

我是否错过了某个属性或重要的一步?

(此属性 sonar.test.inclusions = **/*.spec.ts 重要吗?)

最佳答案

can you try to add property sonar.tests=. (value set to current directory) – Tibor Blenessy

在 Sonar 配置中添加此属性对我有用。

当我设置了属性 sonar.tests 但没有设置 sonar.test.inclusions 时,我收到了错误,但是有了这两个属性,一切正常。

关于javascript - 将 Angular 单元测试报告导入 Sonarqube,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49539155/

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