Skip to content

Commit

Permalink
Add more data to the generated junit results
Browse files Browse the repository at this point in the history
Add some information that some tools looking to parse the junit results
are expecting to be present.
  • Loading branch information
omajid committed Apr 14, 2020
1 parent 33cb5c6 commit 9912c2f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Turkey.Tests/TestOutputFormatTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public async Task EmptyResultsProduceBasicXml()
var xml = File.ReadAllText(resultsFile.FullName);

var expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<testsuite />";
<testsuite name=""dotnet"" tests=""0"" failures=""0"" errors=""0"" />";

Assert.Equal(expectedXml, xml);

Expand All @@ -36,7 +36,7 @@ public async Task SingleTestWithPassingResultProducesValidXml()
var xml = File.ReadAllText(resultsFile.FullName);

var expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<testsuite>
<testsuite name=""dotnet"" tests=""1"" failures=""0"" errors=""0"">
<testcase name=""foo"" classname=""TestSuite"">
<system-out></system-out>
<system-err></system-err>
Expand All @@ -62,7 +62,7 @@ public async Task ControlCharactersInTestOutputAreNotPresentInXml()
var xml = File.ReadAllText(resultsFile.FullName);

var expectedXml = @"<?xml version=""1.0"" encoding=""utf-8""?>
<testsuite>
<testsuite name=""dotnet"" tests=""1"" failures=""0"" errors=""0"">
<testcase name=""foo"" classname=""TestSuite"">
<system-out>aaa</system-out>
<system-err>bbb</system-err>
Expand Down
5 changes: 5 additions & 0 deletions Turkey/TestOutputFormat.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Xml;
Expand Down Expand Up @@ -165,6 +166,10 @@ public async override Task AfterRunningAllTestsAsync(TestResults results)
writer.WriteStartDocument();

writer.WriteStartElement("testsuite");
writer.WriteAttributeString("name", "dotnet");
writer.WriteAttributeString("tests", _testCases.Count.ToString());
writer.WriteAttributeString("failures", _testCases.Where(t => t.Failed).Count().ToString());
writer.WriteAttributeString("errors", "0");

foreach (var testCase in _testCases)
{
Expand Down

0 comments on commit 9912c2f

Please sign in to comment.