Skip to content

Commit

Permalink
Merge pull request #34 from maxisam/fix/no-test
Browse files Browse the repository at this point in the history
fix: no test in test report
  • Loading branch information
bibipkins authored Oct 9, 2023
2 parents 311db8b + a5a4ced commit 8054377
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,9 @@ const parseSummary = (file) => {
};
};
const parseResults = (file) => {
if (!file.TestRun.Results || !file.TestRun.Results[0].UnitTestResult) {
return [];
}
const results = file.TestRun.Results[0].UnitTestResult;
return results.map((result) => {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
Expand All @@ -562,6 +565,9 @@ const parseResults = (file) => {
});
};
const parseDefinitions = (file) => {
if (!file.TestRun.TestDefinitions || !file.TestRun.TestDefinitions[0].UnitTest) {
return [];
}
const definitions = file.TestRun.TestDefinitions[0].UnitTest;
return definitions.map(definition => {
var _a;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions files/success/test_result_none.trx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<TestRun id="a58a7448-16d3-424b-af39-0baf72d6b0fc" name="testuser@DESKTOP-QRVC9QF 2022-12-18 21:58:20" runUser="DESKTOP-QRVC9QF\testuser" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Times creation="2022-12-18T21:58:20.5022082+02:00" queuing="2022-12-18T21:58:20.5022086+02:00" start="2022-12-18T21:58:14.7526261+02:00" finish="2022-12-18T21:58:20.7153349+02:00" />
<TestSettings name="default" id="ec7ad54f-e81c-498a-ba43-a6ba36aafe51">
<Deployment runDeploymentRoot="testuser_DESKTOP-QRVC9QF_2022-12-18_21_58_20" />
</TestSettings>
<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="0" executed="0" passed="0" 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" />
<Output>
<StdOut>[xUnit.net 00:00:00.00] xUnit.net VSTest Adapter v2.4.5+1caef2f33e (64-bit .NET 6.0.12)&#xD;
[xUnit.net 00:00:03.80] Discovering: UnitTests&#xD;
[xUnit.net 00:00:04.01] Discovered: UnitTests&#xD;
[xUnit.net 00:00:04.01] Starting: UnitTests&#xD;
[xUnit.net 00:00:04.27] Finished: UnitTests&#xD;
</StdOut>
</Output>
</ResultSummary>
</TestRun>
8 changes: 7 additions & 1 deletion src/parsers/trx.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ResultParser, ITestSuit, TestOutcome } from '../data';
import { ITestSuit, ResultParser, TestOutcome } from '../data';
import { readXmlFile } from '../utils';

const parseTrx: ResultParser = async (filePath: string) => {
Expand Down Expand Up @@ -41,6 +41,9 @@ const parseSummary = (file: any) => {
};

const parseResults = (file: any) => {
if (!file.TestRun.Results || !file.TestRun.Results[0].UnitTestResult) {
return [];
}
const results = file.TestRun.Results[0].UnitTestResult as any[];

return results.map((result: any) => ({
Expand All @@ -62,6 +65,9 @@ const parseResults = (file: any) => {
};

const parseDefinitions = (file: any) => {
if (!file.TestRun.TestDefinitions || !file.TestRun.TestDefinitions[0].UnitTest) {
return [];
}
const definitions = file.TestRun.TestDefinitions[0].UnitTest as any[];

return definitions.map(definition => ({
Expand Down

0 comments on commit 8054377

Please sign in to comment.