Skip to content

Commit 84e60ba

Browse files
committed
Merge branch 'upstream-main' into ritchxu/support-actions-summary
2 parents 1db4305 + e052c7d commit 84e60ba

37 files changed

+2135
-1342
lines changed

.github/workflows/check-dist.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ jobs:
4646
id: diff
4747

4848
# If index.js was different than expected, upload the expected version as an artifact
49-
- uses: actions/upload-artifact@v3
49+
- uses: actions/upload-artifact@v4
5050
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
5151
with:
5252
name: dist

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: Upload test results
2727
if: success() || failure()
28-
uses: actions/upload-artifact@v3
28+
uses: actions/upload-artifact@v4
2929
with:
3030
name: test-results
3131
path: __tests__/__results__/*.xml

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.19.0
1+
v20

README.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This [Github Action](https://github.com/features/actions) displays test results
1313
|:--:|:--:|:--:|:--:|
1414

1515
**Supported languages / frameworks:**
16-
- .NET / [xUnit](https://xunit.net/) / [NUnit](https://nunit.org/) / [MSTest](https://github.com/Microsoft/testfx-docs)
16+
- .NET / [dotnet test](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#examples) ( [xUnit](https://xunit.net/) / [NUnit](https://nunit.org/) / [MSTest](https://github.com/Microsoft/testfx-docs) )
1717
- Dart / [test](https://pub.dev/packages/test)
1818
- Flutter / [test](https://pub.dev/packages/test)
1919
- Java / [JUnit](https://junit.org/)
@@ -43,7 +43,7 @@ jobs:
4343
name: Build & Test
4444
runs-on: ubuntu-latest
4545
steps:
46-
- uses: actions/checkout@v3 # checkout the repo
46+
- uses: actions/checkout@v4 # checkout the repo
4747
- run: npm ci # install packages
4848
- run: npm test # run tests (configured to use jest-junit reporter)
4949

@@ -74,10 +74,10 @@ jobs:
7474
build-test:
7575
runs-on: ubuntu-latest
7676
steps:
77-
- uses: actions/checkout@v3 # checkout the repo
77+
- uses: actions/checkout@v4 # checkout the repo
7878
- run: npm ci # install packages
7979
- run: npm test # run tests (configured to use jest-junit reporter)
80-
- uses: actions/upload-artifact@v3 # upload test results
80+
- uses: actions/upload-artifact@v4 # upload test results
8181
if: success() || failure() # run this step even if previous step failed
8282
with:
8383
name: test-results
@@ -137,11 +137,13 @@ jobs:
137137
138138
# Format of test results. Supported options:
139139
# dart-json
140+
# dotnet-nunit
140141
# dotnet-trx
141142
# flutter-json
142143
# java-junit
143144
# jest-junit
144145
# mocha-json
146+
# rspec-json
145147
reporter: ''
146148
147149
# Allows you to generate only the summary.
@@ -315,16 +317,22 @@ Configuration of `uniqueOutputName`, `suiteNameTemplate`, `classNameTemplate`, `
315317
- Mocha version [v7.2.0](https://github.com/mochajs/mocha/releases/tag/v7.2.0) or higher
316318
- Usage of [json](https://mochajs.org/#json) reporter.
317319

318-
You can use the following example configuration in `package.json`:
320+
For Mocha >= [v9.1.0](https://github.com/mochajs/mocha/releases/tag/v9.1.0), you can use the following example configuration in `package.json`:
319321
```json
320322
"scripts": {
321-
"test": "mocha --reporter json > test-results.json"
323+
"test": "mocha --reporter json --reporter-option output=test-results.json"
322324
}
323325
```
324326

325-
Test processing might fail if any of your tests write anything on standard output.
326-
Mocha, unfortunately, doesn't have the option to store `json` output directly to the file, and we have to rely on redirecting its standard output.
327-
There is a work in progress to fix it: [mocha#4607](https://github.com/mochajs/mocha/pull/4607)
327+
For Mocha < v9.1, the command should look like this:
328+
```json
329+
"scripts": {
330+
"test": "mocha --reporter json > test-results.json"
331+
}
332+
```
333+
Additionally, test processing might fail if any of your tests write anything on standard output.
334+
Before version [v9.1.0](https://github.com/mochajs/mocha/releases/tag/v9.1.0), Mocha doesn't have the option to store `json` output directly to the file, and we have to rely on redirecting its standard output ([mocha#4607](https://github.com/mochajs/mocha/pull/4607)).
335+
Please update Mocha to version [v9.1.0](https://github.com/mochajs/mocha/releases/tag/v9.1.0) or above if you encounter this issue.
328336
</details>
329337

330338
<details>
@@ -339,7 +347,7 @@ Unfortunately, there are some known issues and limitations caused by GitHub API:
339347

340348
- Test report (i.e. Check Run summary) is markdown text. No custom styling or HTML is possible.
341349
- Maximum report size is 65535 bytes. Input parameters `list-suites` and `list-tests` will be automatically adjusted if max size is exceeded.
342-
- Test report can't reference any additional files (e.g. screenshots). You can use `actions/upload-artifact@v3` to upload them and inspect them manually.
350+
- Test report can't reference any additional files (e.g. screenshots). You can use `actions/upload-artifact@v4` to upload them and inspect them manually.
343351
- Check Runs are created for specific commit SHA. It's not possible to specify under which workflow test report should belong if more
344352
workflows are running for the same SHA. Thanks to this GitHub "feature" it's possible your test report will appear in an unexpected place in GitHub UI.
345353
For more information, see [#67](https://github.com/dorny/test-reporter/issues/67).

__tests__/__outputs__/dotnet-nunit.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
![Tests failed](https://img.shields.io/badge/tests-3%20passed%2C%205%20failed%2C%201%20skipped-critical)
2+
|Report|Passed|Failed|Skipped|Time|
3+
|:---|---:|---:|---:|---:|
4+
|fixtures/dotnet-nunit.xml|3 ✅|5 ❌|1 ⚪|230ms|
5+
## ❌ <a id="user-content-r0" href="#r0">fixtures/dotnet-nunit.xml</a>
6+
**9** tests were completed in **230ms** with **3** passed, **5** failed and **1** skipped.
7+
|Test suite|Passed|Failed|Skipped|Time|
8+
|:---|---:|---:|---:|---:|
9+
|[DotnetTests.NUnitV3Tests.dll.DotnetTests.XUnitTests](#r0s0)|3 ✅|5 ❌|1 ⚪|69ms|
10+
### ❌ <a id="user-content-r0s0" href="#r0s0">DotnetTests.NUnitV3Tests.dll.DotnetTests.XUnitTests</a>
11+
```
12+
CalculatorTests
13+
✅ Is_Even_Number(2)
14+
❌ Is_Even_Number(3)
15+
Expected: True
16+
But was: False
17+
18+
❌ Exception_In_TargetTest
19+
System.DivideByZeroException : Attempted to divide by zero.
20+
❌ Exception_In_Test
21+
System.Exception : Test
22+
❌ Failing_Test
23+
Expected: 3
24+
But was: 2
25+
26+
✅ Passing_Test
27+
✅ Passing_Test_With_Description
28+
⚪ Skipped_Test
29+
❌ Timeout_Test
30+
31+
```

__tests__/__outputs__/rspec-json.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
![Tests failed](https://img.shields.io/badge/tests-1%20passed%2C%201%20failed%2C%201%20skipped-critical)
2+
|Report|Passed|Failed|Skipped|Time|
3+
|:---|---:|---:|---:|---:|
4+
|fixtures/rspec-json.json|1 ✅|1 ❌|1 ⚪|0ms|
5+
## ❌ <a id="user-content-r0" href="#r0">fixtures/rspec-json.json</a>
6+
**3** tests were completed in **0ms** with **1** passed, **1** failed and **1** skipped.
7+
|Test suite|Passed|Failed|Skipped|Time|
8+
|:---|---:|---:|---:|---:|
9+
|[./spec/config/check_env_vars_spec.rb](#r0s0)|1 ✅|1 ❌|1 ⚪|0ms|
10+
### ❌ <a id="user-content-r0s0" href="#r0s0">./spec/config/check_env_vars_spec.rb</a>
11+
```
12+
CheckEnvVars#call when all env vars are defined behaves like success load
13+
❌ CheckEnvVars#call when all env vars are defined behaves like success load fails in assertion
14+
(#ActiveSupport::BroadcastLogger:0x00007f1007fedf58).debug("All config env vars exist")
15+
expected: 0 times with arguments: ("All config env vars exist")
16+
received: 1 time with arguments: ("All config env vars exist")
17+
✅ CheckEnvVars#call when all env vars are defined behaves like success load logs success message
18+
⚪ CheckEnvVars#call when all env vars are defined behaves like success load skips the test
19+
```

__tests__/__outputs__/swift-xunit.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ AcmeLibTests.AcmeLibTests
1313
✅ test_always_pass
1414
✅ test_always_skip
1515
❌ test_always_fail
16+
failed
1617
```
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`dotnet-nunit tests report from ./reports/dotnet test results matches snapshot 1`] = `
4+
TestRunResult {
5+
"path": "fixtures/dotnet-nunit.xml",
6+
"suites": [
7+
TestSuiteResult {
8+
"groups": [
9+
TestGroupResult {
10+
"name": "CalculatorTests",
11+
"tests": [
12+
TestCaseResult {
13+
"error": undefined,
14+
"name": "Is_Even_Number(2)",
15+
"result": "success",
16+
"time": 0.622,
17+
},
18+
TestCaseResult {
19+
"error": {
20+
"details": " at DotnetTests.XUnitTests.CalculatorTests.Is_Even_Number(Int32 i) in C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\dotnet\\DotnetTests.NUnitV3Tests\\CalculatorTests.cs:line 61
21+
",
22+
"line": undefined,
23+
"message": " Expected: True
24+
But was: False
25+
",
26+
"path": undefined,
27+
},
28+
"name": "Is_Even_Number(3)",
29+
"result": "failed",
30+
"time": 1.098,
31+
},
32+
TestCaseResult {
33+
"error": {
34+
"details": " at DotnetTests.Unit.Calculator.Div(Int32 a, Int32 b) in C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\dotnet\\DotnetTests.Unit\\Calculator.cs:line 9
35+
at DotnetTests.XUnitTests.CalculatorTests.Exception_In_TargetTest() in C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\dotnet\\DotnetTests.NUnitV3Tests\\CalculatorTests.cs:line 33",
36+
"line": undefined,
37+
"message": "System.DivideByZeroException : Attempted to divide by zero.",
38+
"path": undefined,
39+
},
40+
"name": "Exception_In_TargetTest",
41+
"result": "failed",
42+
"time": 22.805,
43+
},
44+
TestCaseResult {
45+
"error": {
46+
"details": " at DotnetTests.XUnitTests.CalculatorTests.Exception_In_Test() in C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\dotnet\\DotnetTests.NUnitV3Tests\\CalculatorTests.cs:line 39",
47+
"line": undefined,
48+
"message": "System.Exception : Test",
49+
"path": undefined,
50+
},
51+
"name": "Exception_In_Test",
52+
"result": "failed",
53+
"time": 0.528,
54+
},
55+
TestCaseResult {
56+
"error": {
57+
"details": " at DotnetTests.XUnitTests.CalculatorTests.Failing_Test() in C:\\Users\\Michal\\Workspace\\dorny\\test-reporter\\reports\\dotnet\\DotnetTests.NUnitV3Tests\\CalculatorTests.cs:line 27
58+
",
59+
"line": undefined,
60+
"message": " Expected: 3
61+
But was: 2
62+
",
63+
"path": undefined,
64+
},
65+
"name": "Failing_Test",
66+
"result": "failed",
67+
"time": 28.162,
68+
},
69+
TestCaseResult {
70+
"error": undefined,
71+
"name": "Passing_Test",
72+
"result": "success",
73+
"time": 0.23800000000000002,
74+
},
75+
TestCaseResult {
76+
"error": undefined,
77+
"name": "Passing_Test_With_Description",
78+
"result": "success",
79+
"time": 0.135,
80+
},
81+
TestCaseResult {
82+
"error": undefined,
83+
"name": "Skipped_Test",
84+
"result": "skipped",
85+
"time": 0.398,
86+
},
87+
TestCaseResult {
88+
"error": {
89+
"details": "",
90+
"line": undefined,
91+
"message": "",
92+
"path": undefined,
93+
},
94+
"name": "Timeout_Test",
95+
"result": "failed",
96+
"time": 14.949,
97+
},
98+
],
99+
},
100+
],
101+
"name": "DotnetTests.NUnitV3Tests.dll.DotnetTests.XUnitTests",
102+
"totalTime": undefined,
103+
},
104+
],
105+
"totalTime": 230.30800000000002,
106+
}
107+
`;

__tests__/__snapshots__/java-junit.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ at java.lang.Thread.run(Thread.java:748)
4141
4242
",
4343
"line": 29,
44-
"message": undefined,
44+
"message": "java.lang.AssertionError: expected [1.2.1] but found [1.2.0]",
4545
"path": "pulsar-common/src/test/java/org/apache/pulsar/AddMissingPatchVersionTest.java",
4646
},
4747
"name": "testVersionStrings",
@@ -100,7 +100,7 @@ at java.lang.Thread.run(Thread.java:748)
100100
101101
",
102102
"line": 29,
103-
"message": undefined,
103+
"message": "java.lang.AssertionError: expected [1.2.1] but found [1.2.0]",
104104
"path": "pulsar-common/src/test/java/org/apache/pulsar/AddMissingPatchVersionTest.java",
105105
},
106106
"name": "testVersionStrings",
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`rspec-json tests report from ./reports/rspec-json test results matches snapshot 1`] = `
4+
TestRunResult {
5+
"path": "fixtures/rspec-json.json",
6+
"suites": [
7+
TestSuiteResult {
8+
"groups": [
9+
TestGroupResult {
10+
"name": "CheckEnvVars#call when all env vars are defined behaves like success load",
11+
"tests": [
12+
TestCaseResult {
13+
"error": {
14+
"details": "/usr/local/bundle/ruby/3.3.0/gems/net-http-0.4.1/lib/net/http.rb:1603:in \`initialize'
15+
./config/check_env_vars.rb:11:in \`call'
16+
./spec/config/check_env_vars_spec.rb:7:in \`block (3 levels) in <top (required)>'
17+
./spec/config/check_env_vars_spec.rb:19:in \`block (4 levels) in <top (required)>'",
18+
"line": 11,
19+
"message": "(#ActiveSupport::BroadcastLogger:0x00007f1007fedf58).debug("All config env vars exist")
20+
expected: 0 times with arguments: ("All config env vars exist")
21+
received: 1 time with arguments: ("All config env vars exist")",
22+
"path": "./config/check_env_vars.rb",
23+
},
24+
"name": "CheckEnvVars#call when all env vars are defined behaves like success load fails in assertion",
25+
"result": "failed",
26+
"time": 0.004411051,
27+
},
28+
TestCaseResult {
29+
"error": undefined,
30+
"name": "CheckEnvVars#call when all env vars are defined behaves like success load logs success message",
31+
"result": "success",
32+
"time": 0.079159625,
33+
},
34+
TestCaseResult {
35+
"error": undefined,
36+
"name": "CheckEnvVars#call when all env vars are defined behaves like success load skips the test",
37+
"result": "skipped",
38+
"time": 0.000023007,
39+
},
40+
],
41+
},
42+
],
43+
"name": "./spec/config/check_env_vars_spec.rb",
44+
"totalTime": undefined,
45+
},
46+
],
47+
"totalTime": 0.19118387,
48+
}
49+
`;

__tests__/__snapshots__/swift-xunit.test.ts.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ TestRunResult {
2525
"error": {
2626
"details": undefined,
2727
"line": undefined,
28-
"message": undefined,
28+
"message": "failed",
2929
"path": undefined,
3030
},
3131
"name": "test_always_fail",

__tests__/dotnet-nunit.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import * as fs from 'fs'
2+
import * as path from 'path'
3+
4+
import {DotnetNunitParser} from '../src/parsers/dotnet-nunit/dotnet-nunit-parser'
5+
import {ParseOptions} from '../src/test-parser'
6+
import {getReport} from '../src/report/get-report'
7+
import {normalizeFilePath} from '../src/utils/path-utils'
8+
9+
describe('dotnet-nunit tests', () => {
10+
it('report from ./reports/dotnet test results matches snapshot', async () => {
11+
const fixturePath = path.join(__dirname, 'fixtures', 'dotnet-nunit.xml')
12+
const outputPath = path.join(__dirname, '__outputs__', 'dotnet-nunit.md')
13+
const filePath = normalizeFilePath(path.relative(__dirname, fixturePath))
14+
const fileContent = fs.readFileSync(fixturePath, {encoding: 'utf8'})
15+
16+
const opts: ParseOptions = {
17+
parseErrors: true,
18+
trackedFiles: ['DotnetTests.Unit/Calculator.cs', 'DotnetTests.NUnitV3Tests/CalculatorTests.cs']
19+
}
20+
21+
const parser = new DotnetNunitParser(opts)
22+
const result = await parser.parse(filePath, fileContent)
23+
expect(result).toMatchSnapshot()
24+
25+
const report = getReport([result])
26+
fs.mkdirSync(path.dirname(outputPath), {recursive: true})
27+
fs.writeFileSync(outputPath, report)
28+
})
29+
})

0 commit comments

Comments
 (0)