Skip to content

Commit

Permalink
Handle zero unit tests (#138)
Browse files Browse the repository at this point in the history
* Handle zero unit tests

* Fixed badge text

* Updated README #138
  • Loading branch information
Nasir Amin authored Apr 14, 2021
1 parent 7257e83 commit 39bdec5
Show file tree
Hide file tree
Showing 14 changed files with 13,681 additions and 97 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,19 @@ jobs:
dotnet test -c Release --no-restore --no-build --loger trx --results-directory ./TestResults
# Using the trx-parser action
- name: Parse Trx files
uses: NasAmin/trx-parser@v0.0.3
uses: NasAmin/trx-parser@v0.1
id: trx-parser
with:
TRX_PATH: ${{ github.workspace }}/TestResults #This should be the path to your TRX files
REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
### ⚠️ GitHub Actions Limitations ⚠️
- The GitHub Checks API has a [limit](https://github.com/github/docs/issues/3765) of `65535` characters. So if the test report exceeds this limit, GitHub will fail to create a check and fail your workflow.
This was mitigated on #103 and #138 to only report details about failing tests.
- If you have multiple workflows triggered by the same event, currently GitHub Actions will randomly associate a check run to one of the workflows. This is because currently there is no Check Suite API. [Only GitHub apps](https://docs.github.com/en/rest/reference/checks#check-suites) are allowed to create a Check Suite. There is also no way to associate a custom check run with an existing check suite.
GitHub actions automatically creates a check suite for each workflow run. However, since check runs are associated with a commit and event, any custom check runs are randomly linked under one of the triggered workflows for the same commit.

## Contributing
Anyone is welcome to contribute and make this action better. Please fork the repository and create a pull request with proposed changes.

Expand Down
36 changes: 36 additions & 0 deletions __tests__/markup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,39 @@ describe('When generating markup for trx', () => {
expect(duration).toEqual(111.407)
})
})

describe('When reading invalid trx file', () => {
test('Load trx with test host error', async () => {
const data = await transformTrxToJson(
'./test-data/failing-tests/test-host-error.trx'
)
const testData = getMarkupForTrx(data)
expect(data.TrxData.TestRun.ResultSummary._outcome).toEqual('Failed')
expect(testData).toContain(
`Test Results - ${data.ReportMetaData.ReportTitle}`
)
expect(testData).toContain(
`Total Tests: ${data.TrxData.TestRun.ResultSummary.Counters._total}`
)
expect(testData).toContain(
`Failed: ${data.TrxData.TestRun.ResultSummary.Counters._failed}`
)
})

test('Parse trx with zero unit tests', async () => {
const data = await transformTrxToJson(
'./test-data/failing-tests/no-tests.trx'
)
const testData = getMarkupForTrx(data)
expect(data.TrxData.TestRun.ResultSummary._outcome).toEqual('Completed')
expect(testData).toContain(
`Test Results - ${data.ReportMetaData.ReportTitle}`
)
expect(testData).toContain(
`Total Tests: ${data.TrxData.TestRun.ResultSummary.Counters._total}`
)
expect(testData).toContain(
`Failed: ${data.TrxData.TestRun.ResultSummary.Counters._failed}`
)
})
})
179 changes: 118 additions & 61 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Binary file modified docs/trx-check-failing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/trx-check-passing.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 39bdec5

Please sign in to comment.