Skip to content

Commit

Permalink
Improve reports loading and clean code
Browse files Browse the repository at this point in the history
- Improve JUnit test reports loading
  - Refine file patterns
  - Load all reports instead of only the first one #2
  - Read only top-level `<testsuite>` tags
- Exclude some directories from file search
- Improve documentation
  - Clarify explanations about reports loading
  - Add more examples
- Clean code (quotes, semicolons, tests, ...)
- Update dependencies
  - Update ESLint to v9
  • Loading branch information
GaelGirodon committed May 22, 2024
1 parent c718821 commit 02121f1
Show file tree
Hide file tree
Showing 21 changed files with 279 additions and 280 deletions.
9 changes: 0 additions & 9 deletions .eslintrc.yml

This file was deleted.

32 changes: 19 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ Only matched report formats will get a file uploaded to the Gist.

### Go

Write the verbose test output (`>` or `tee`) with coverage enabled to a
Write the verbose test output (`>` or `tee`) with coverage enabled to a single
`test*.{out,txt}` file next to the `go.mod` file:

- `RUN`, `PASS` and `FAIL` flags will be used to count tests
Expand All @@ -100,21 +100,26 @@ sure the last percentage is the global coverage value.

### JUnit

Write the test report to a file matching:
Write test report(s) to file(s) matching:

- `**/TEST-*.xml`
- `**/report.xml`
- `**/*TEST*.xml`
- `**/*test*.xml`
- `**/*junit*.xml`

This is the default format and location with JUnit, but most test runners
support this format too, natively or using an additional reporter, e.g.:

- **Mocha**: `mocha --reporter mocha-junit-reporter`
- **Jest**: `jest --reporters="jest-junit"`
support this format too, natively or using an additional reporter:

- **Maven**: `mvn test` → `target/{surefire,failsafe}-reports/TEST-*.xml`
- **Gradle**: `gradle test` → `build/test-results/test/**/TEST-*.xml`
- **Node.js**: `node --test --test-reporter=junit --test-reporter-destination=report.xml`
- **Mocha**: `mocha --reporter mocha-junit-reporter` → `test-results.xml`
- **Jest**: `jest --reporters="jest-junit"` → `junit.xml`
- **Deno**: `deno test --junit-path=report.xml`
- **PHPUnit**: `phpunit --log-junit report.xml`

The number of tests and failures will be extracted from `<testsuite>` tags.
The number of tests and failures will be extracted from top-level `<testsuite>`
tags, from all matching and valid report files.

➡️ `{repo}-[{ref}-]junit-tests.json`

Expand All @@ -126,14 +131,14 @@ Write the coverage report to a file matching:
- `**/*coverage*.xml`

This is the default format and location with Cobertura, but most code coverage
tools support this format too, natively or using an additional reporter, e.g.:
tools support this format too, natively or using an additional reporter:

- **c8**: `c8 --reporter cobertura [...]`
- **nyc**: `nyc --reporter cobertura [...]`
- **c8**: `c8 --reporter cobertura [...]` → `coverage/cobertura-coverage.xml`
- **nyc**: `nyc --reporter cobertura [...]` → `coverage/cobertura-coverage.xml`
- **PHPUnit**: `phpunit --coverage-cobertura coverage.xml`

The coverage will be extracted from the `line-rate` attribute of the
`<coverage>` tag.
`<coverage>` tag, from the first matching and valid report file.

➡️ `{repo}-[{ref}-]cobertura-coverage.json`

Expand All @@ -147,7 +152,8 @@ Write the coverage report to a file matching:
This is the default format and location with JaCoCo, but some code coverage
tools may support this format too.

The coverage will be extracted from the last `<counter>` tag with type `LINE`.
The coverage will be extracted from the last `<counter>` tag with type `LINE`,
from the first matching and valid report file.

➡️ `{repo}-[{ref}-]jacoco-coverage.json`

Expand Down
8 changes: 8 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import globals from 'globals';
import pluginJs from '@eslint/js';

export default [
{ languageOptions: { globals: globals.node } },
{ languageOptions: { globals: globals.mocha } },
pluginJs.configs.recommended
];
Loading

0 comments on commit 02121f1

Please sign in to comment.