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

Handle zero unit tests #138

Merged
merged 3 commits into from
Apr 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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