Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly merge test cases into the existing coverage tree #98

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

uhafner
Copy link
Member

@uhafner uhafner commented Apr 22, 2024

The mapping is done by evaluating the name of the test class. If the name of the test class cannot be mapped to a target class, then the tests of this test class are ignored. All unmapped test classes will be retained so that they can be visualized differently.

The mapping is done by evaluating the name of the test class. If the
name of the test class cannot be mapped to a target class, then the
tests of this test class are ignored. All unmapped test classes will be
retained so that they can be visualized differently.
@uhafner uhafner added the bug Bugs or performance problems label Apr 22, 2024
Copy link

☀️   Quality Monitor

   🚦   Tests: 100 % successful (✔️ 291 passed)
   〰️   Line Coverage: 98% (49 missed lines)
   ➰   Branch Coverage: 94% (51 missed branches)
   PIT   Mutation Coverage: 93% (75 survived mutations)
   CheckStyle   CheckStyle: No warnings found
   PMD   PMD: No warnings found
   SpotBugs   SpotBugs: No warnings found

Created by Quality Monitor v1.7.0 (#823c682). More details are shown in the GitHub Checks Result.

@uhafner
Copy link
Member Author

uhafner commented Apr 22, 2024

Required for jenkinsci/coverage-plugin#118

@uhafner uhafner merged commit 2aedb63 into main Apr 22, 2024
30 checks passed
@uhafner uhafner deleted the test-case-mapping branch April 22, 2024 17:19
@jonesbusy
Copy link
Contributor

jonesbusy commented Apr 26, 2024

Hi,

I think this cause some regression for me

05:42:26.799+02:00] - Error when executing always post condition:
[05:42:26.818+02:00] - Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: b9f1eb15-fe39-4322-bf2a-b2b681bda2a6
[05:42:26.818+02:00] - java.lang.IllegalArgumentException: There is already a child [PACKAGE] - <0> with the name - in [CONTAINER] Container <2, LINE: 9.54% (25/262)>
[05:42:26.818+02:00] - 	at edu.hm.hafner.coverage.Node.addChild(Node.java:167)
[05:42:26.818+02:00] - 	at io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder.createPackage(CoverageRecorder.java:565)
[05:42:26.818+02:00] - 	at io.jenkins.plugins.coverage.metrics.steps.CoverageRecorder.lambda$mapTests$6(CoverageRecorder.java:560)
[05:42:26.818+02:00] - 	at java.base/java.util.Optional.orElseGet(Unknown Source)

I'm doing something like

recordCoverage(
 tools: [
   [parser: 'JACOCO', pattern: 'backend/target/site/jacoco/jacoco.xml'],
   [parser: 'COBERTURA', pattern: 'frontend/coverage/cobertura-coverage.xml'],
   [parser: 'JUNIT', pattern: 'backend/target/surefire-reports/TEST-*.xml,backend/target/failsafe-reports/TEST-*.xml,frontend/junit.xml']
        ],
        failOnError: false

I was checking my report they don't have duplicate, they are too different application and techo.

Not sure what's going on there

The frontend/junit.xml looks like this

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="1" failures="0" errors="0" time="2.395">
  <testsuite name="Todo" errors="0" failures="0" skipped="0" timestamp="2024-04-26T04:27:11" time="1.927" tests="1">
    <testcase classname="Todo should correctly set properties" name="Todo should correctly set properties" time="0.004">
    </testcase>
  </testsuite>
</testsuites>

And using something like to generate the JUNIT format

JEST_SONAR_OUTPUT_DIR=sonar-results jest --coverage --coverageDirectory=coverage --reporters=default --reporters=jest-junit --reporters=jest-sonar

I confirm if I remove the frontend/junit.xml I can execute the coverage.

Before the update of the plugin I was able to get a test report.

I'm wondering if it's related to the '-' package name ?

before_merge

@jonesbusy
Copy link
Contributor

Nevermind. I was able to fix the issue by changing the class name for the jest-junit reporter

  "jest-junit": {
    "suiteName": "frontend",
    "classNameTemplate": "{filepath}"
  }

I'm wonder if it was because of spaces inside class name. Changing to the file path creates a package

merge_ok

@uhafner
Copy link
Member Author

uhafner commented Apr 26, 2024

"-" is used as fallback if no top-level name is available. Maybe I need to look again at the merging process if there are several files that could not be merged and therefore appear under a new tree root. Maybe I should call it unmapped...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bugs or performance problems
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants