Skip to content

Commit

Permalink
Merge pull request #25 from gfoidl/nunit-no-tests-bug-issue24
Browse files Browse the repository at this point in the history
TrxParser is tolerant against missing values
  • Loading branch information
gfoidl committed Nov 13, 2018
2 parents 4d8d06a + 278aa4c commit a9511e9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/trx2junit/Internal/TrxParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ private void ReadTestDefinitions()
{
XElement xTestDefinitions = _trx.Element(s_XN + "TestDefinitions");

if (xTestDefinitions == null) return;

foreach (XElement xUnitTest in xTestDefinitions.Elements())
{
var testDefinition = new TestDefinition
Expand All @@ -83,6 +85,8 @@ private void ReadUnitTestResults()
{
XElement xResults = _trx.Element(s_XN + "Results");

if (xResults == null) return;

foreach (XElement xResult in xResults.Elements())
{
var unitTestResult = new UnitTestResult
Expand Down
8 changes: 8 additions & 0 deletions tests/trx2junit.Tests/Internal/TrxParserTests/Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public void Parse_NUnit___OK()
}
//---------------------------------------------------------------------
[Test]
public void Parse_NUnit_with_no_tests___OK()
{
Models.Test actual = this.ParseCore("./data/nunit-no-tests.trx");

Assert.IsNotNull(actual);
}
//---------------------------------------------------------------------
[Test]
public void Parse_MsTest___OK()
{
Models.Test actual = this.ParseCore("./data/mstest.trx");
Expand Down
2 changes: 2 additions & 0 deletions tests/trx2junit.Tests/WorkerTests/Convert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Convert
[TestCase("./data/nunit.trx")]
[TestCase("./data/mstest.trx")]
[TestCase("./data/mstest-warning.trx")]
[TestCase("./data/nunit-no-tests.trx")]
public async Task File_given___converted(string trxFile)
{
string junitFile = Path.ChangeExtension(trxFile, "xml");
Expand All @@ -28,6 +29,7 @@ public async Task File_given___converted(string trxFile)
[TestCase("./data/nunit.trx")]
[TestCase("./data/mstest.trx")]
[TestCase("./data/mstest-warning.trx")]
[TestCase("./data/nunit-no-tests.trx")]
public async Task File_given___generated_xml_is_valid_against_schema(string trxFile)
{
string junitFile = Path.ChangeExtension(trxFile, "xml");
Expand Down
22 changes: 22 additions & 0 deletions tests/trx2junit.Tests/data/nunit-no-tests.trx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<TestRun id="ebd14c86-c0ed-4e77-936f-455116621735" name="@db218a987583 2018-11-13 22:40:12" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Times creation="2018-11-13T22:40:12.4876192+00:00" queuing="2018-11-13T22:40:12.4876194+00:00" start="2018-11-13T22:40:11.7576546+00:00" finish="2018-11-13T22:40:12.5000059+00:00" />
<TestSettings name="default" id="072fbc10-f1f2-4da2-8594-ddd4a4ac2c50">
<Deployment runDeploymentRoot="_db218a987583_2018-11-13_22_40_12" />
</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>NUnit Adapter 3.11.0.0: Test execution startedRunning all tests in /root/repo/tests/my/bin/Release/netcoreapp2.1/my.dll NUnit couldn't find any tests in /root/repo/tests/my/bin/Release/netcoreapp2.1/my.dll NUnit Adapter 3.11.0.0: Test execution complete</StdOut>
</Output>
<RunInfos>
<RunInfo computerName="db218a987583" outcome="Warning" timestamp="2018-11-13T22:40:12.4156993+00:00">
<Text>No test is available in /root/repo/tests/my/bin/Release/netcoreapp2.1/my.dll. Make sure that test discoverer &amp; executors are registered and platform &amp; framework version settings are appropriate and try again.</Text>
</RunInfo>
</RunInfos>
</ResultSummary>
</TestRun>

0 comments on commit a9511e9

Please sign in to comment.