当前位置: 首页 > 知识库问答 >
问题:

将角单元测试报告导入Sonarqube

陈霄
2023-03-14

语境

在一个使用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.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

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

共有1个答案

颜志学
2023-03-14

您能否尝试添加属性sonar.tests=。(值设置为当前目录)-Tibor Blenessy

在声纳配置中添加这个属性对我来说很有效。

当我设置了sonar.tests属性但没有设置sonar.test.inclusions时,我得到了一个错误,但是有了这两个属性,一切都很好。

 类似资料:
  • 22.13.7.测试报告 测试任务默认生成以下结果. 一份HTML测试报告 一个与Ant的JUnit测试报告任务兼容的XML.这个格式与许多其他服务兼容,如CI serves 结果是有效的二进制,测试任务会从这些二进制结果生成其他结果。 有一个独立的TestReport任务类型会根据一些Test任务实例生成的二进制源码生成一个HTML报告.使用这种测试类型,需要定义一个destinationDir

  • 当运行单元测试的时候,Gradle 会输出一份 HTML 格式的报告以方便查看结果。Android plugin 则将所有连接设备的测试报告都合并到一个 HTML 格式的报告文件中。所有测试结果都以 XML 文件形式保存到 build/reports/androidTests/ 中(类似于 JUnit 的运行结果保存在 build/reports/tests 中)。可以自定义路径: android

  • 5.4 测试报告 当运行单元测试的时候,Gradle 会生成一份 HTML 报告以便于查看测试结果。 Android plugins 在这个基础上扩展了 HTML 报告,以合并所有已连接设备上的测试结果。 5.4.1 单工程报告 在运行测试的时候工程会自动的生成报告,默认位置是: build/reports/androidTests 这和 jUnit 报告的位置 build/reports/tes

  • 我的项目结构如下: 在Jenkins工作中,根pom是(因为我希望整个项目是为功能覆盖的JaCoCo报告构建的),当运行覆盖报告生成的Maven目标时,我将pom指定为模块FT/pom.xml. 现在,当显示测试结果时,它向我显示了一个总的being=FTs其他模块中的所有单元测试,而我想从报告生成中排除UTs。 但我不认为这与杰科科有关,因为我说的不是杰科科的报告,而是测试结果。单元测试也被计算

  • xccov工具仅为覆盖的代码行生成单元测试覆盖率报告。如果你举个例子。swift文件有20行,10行由单元测试覆盖,覆盖率为50%。 Karma(用于Angular 2开发)不仅为所涵盖的代码行创建报告,还为语句、分支和函数创建报告。 是否可以配置xccov,或者在iOS开发中是否有类似的工具来实现这一点?谢谢

  • 在我认为是彻底的谷歌搜索后,我只能找到一种方法来做这件事与声纳。有没有更简单的方法可以做到这一点? 相关问题:Maven分离单元测试和集成测试