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

Add support for windows generated trx #268

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
- name: Get Source Code
uses: actions/checkout@v2
- name: Restore Dependencies
run: npm ci
run: |
# todo: resolve npm dependency conflicts and than remove the --legacy-peer-deps option
npm ci --legacy-peer-deps
Comment on lines -17 to +19
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have fixed the peer deps, can you please rebase from main and revert this change?

- name: Build
run: npm run all
14 changes: 14 additions & 0 deletions __tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ describe('when loading xml from a trx file', () => {
const data = await transformTrxToJson(
'./test-data/passing-tests/logger.trx'
)
expect(data.ReportMetaData.ReportTitle).toEqual('LOGGER')
expect(data.TrxData.TestRun.ResultSummary._outcome).toEqual('Completed')
expect(data.TrxData.TestRun.ResultSummary.Counters._total).toEqual(21)
expect(data.TrxData.TestRun.ResultSummary.Counters._passed).toEqual(10)
Expand All @@ -33,6 +34,7 @@ describe('when loading xml from a trx file', () => {
const data = await transformTrxToJson(
'./test-data/failing-tests/dummy-tests.trx'
)
expect(data.ReportMetaData.ReportTitle).toEqual('DUMMY-TESTS')
expect(data.TrxData.TestRun.ResultSummary._outcome).toEqual('Failed')
expect(data.TrxData.TestRun.ResultSummary.Counters._total).toEqual(4)
expect(data.TrxData.TestRun.ResultSummary.Counters._passed).toEqual(3)
Expand All @@ -43,6 +45,18 @@ describe('when loading xml from a trx file', () => {
const data = await transformTrxToJson(
'./test-data/passing-tests/single-test.trx'
)
expect(data.ReportMetaData.ReportTitle).toEqual('SINGLE-TEST')
expect(data.TrxData.TestRun.ResultSummary._outcome).toEqual('Completed')
expect(data.TrxData.TestRun.ResultSummary.Counters._total).toEqual(1)
expect(data.TrxData.TestRun.ResultSummary.Counters._passed).toEqual(1)
expect(data.TrxData.TestRun.ResultSummary.Counters._failed).toEqual(0)
})

test('Test Data with a windows test', async () => {
const data = await transformTrxToJson(
'./test-data/passing-tests/windows-test.trx'
)
expect(data.ReportMetaData.ReportTitle).toEqual('WINDOWS-TEST')
expect(data.TrxData.TestRun.ResultSummary._outcome).toEqual('Completed')
expect(data.TrxData.TestRun.ResultSummary.Counters._total).toEqual(1)
expect(data.TrxData.TestRun.ResultSummary.Counters._passed).toEqual(1)
Expand Down
23 changes: 19 additions & 4 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.

15 changes: 5 additions & 10 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ function getReportHeaders(

const storage = getAssemblyName(unittests)

const dllName = storage.split('/').pop()
const isWindows = /^[a-z]:\\/i.test(storage)
const dllName = isWindows
? storage.split('\\').pop()
: storage.split('/').pop()

if (dllName) {
reportTitle = dllName.replace('.dll', '').toUpperCase().replace('.', ' ')
Expand Down
26 changes: 26 additions & 0 deletions test-data/passing-tests/windows-test.trx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<TestRun id="2e7e24eb-5c24-4668-88ff-0f919fd93ad2" name="@staging-tests-vr4mc 2020-10-09 12:16:32" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Times creation="2020-10-09T12:16:32.9539305+00:00" queuing="2020-10-09T12:16:32.9539306+00:00" start="2020-10-09T12:16:32.2264855+00:00" finish="2020-10-09T12:16:32.9675358+00:00" />
<TestSettings name="default" id="3a3b0c56-0f27-46ab-bc0e-aebca223aed0">
<Deployment runDeploymentRoot="_staging-tests-vr4mc_2020-10-09_12_16_32" />
</TestSettings>
<Results>
<UnitTestResult executionId="b12e5ed8-c0b7-47e7-b76b-4b3c9d262807" testId="53a8c29f-d792-c64e-2275-b7d8e947a475" testName="TestMethod1" computerName="staging-tests-vr4mc" duration="00:00:00.0030063" startTime="2020-10-09T12:16:32.7704613+00:00" endTime="2020-10-09T12:16:32.7986250+00:00" testType="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b" outcome="Passed" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" relativeResultsDirectory="b12e5ed8-c0b7-47e7-b76b-4b3c9d262807" />
</Results>
<TestDefinitions>
<UnitTest name="TestMethod1" storage="c:\mytests\bin\release\netcoreapp3.1\windows-test.dll" id="53a8c29f-d792-c64e-2275-b7d8e947a475">
<Execution id="b12e5ed8-c0b7-47e7-b76b-4b3c9d262807" />
<TestMethod codeBase="c:\mytests\bin\release\netcoreapp3.1\windows-test.dll" adapterTypeName="executor://mstestadapter/v2" className="dummy_tests.DummyTest1" name="TestMethod1" />
</UnitTest>
</TestDefinitions>
<TestEntries>
<TestEntry testId="53a8c29f-d792-c64e-2275-b7d8e947a475" executionId="b12e5ed8-c0b7-47e7-b76b-4b3c9d262807" testListId="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
</TestEntries>
<TestLists>
<TestList name="Results Not in a List" id="8c84fa94-04c1-424b-9868-57a2d4851a1d" />
<TestList name="All Loaded Results" id="19431567-8539-422a-85d7-44ee4e166bda" />
</TestLists>
<ResultSummary outcome="Completed">
<Counters total="1" executed="1" passed="1" failed="0" error="0" timeout="0" aborted="0" inconclusive="0" passedButRunAborted="0" notRunnable="0" notExecuted="0" disconnected="0" warning="0" completed="0" inProgress="0" pending="0" />
</ResultSummary>
</TestRun>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert a new line please.