Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
JUnit output report
Browse files Browse the repository at this point in the history
  • Loading branch information
unickq committed Sep 29, 2017
1 parent 2c09637 commit 8f6ea7a
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions CNUnit/Commands/RunCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private void RunTests()
});
allProcesses.Wait();
Utils.WriteLine("Test execution finished", ConsoleColor.Cyan);
if (CNUnit_ReportType == ReportType.NUnit3) NUnitXmlUpdate(xmlList);
NUnitXmlUpdate(xmlList);
}

/// <summary>
Expand Down Expand Up @@ -286,14 +286,30 @@ private void NUnitXmlUpdate(List<string> xmls)
{
foreach (var xml in xmls)
{
Console.WriteLine("!!!!");
var doc = new XmlDocument();
doc.LoadXml(File.ReadAllText(xml));
var attributeCollection = doc.DocumentElement?.SelectNodes("//test-suite")?[0].Attributes;
if (attributeCollection != null)
if (CNUnit_ReportType == ReportType.JUnit)
{
var xmlAttributeCollection = attributeCollection?["name"];
xmlAttributeCollection.Value = Path.GetFileNameWithoutExtension(xml);
var testSuiteNodeList = doc.DocumentElement?.SelectNodes("//testsuite");
if (testSuiteNodeList != null)
foreach (XmlNode testSuiteNode in testSuiteNodeList)
{
if (testSuiteNode.Attributes != null)
testSuiteNode.Attributes["name"].Value =
Path.GetFileNameWithoutExtension(xml)+ "."+ Path.GetRandomFileName();
}
}
else
{
var attributeCollection = doc.DocumentElement?.SelectNodes("//test-suite")?[0].Attributes;
if (attributeCollection != null)
{
var xmlAttributeCollection = attributeCollection?["name"];
xmlAttributeCollection.Value = Path.GetFileNameWithoutExtension(xml);
}
}

doc.Save(xml);
}
}
Expand Down

0 comments on commit 8f6ea7a

Please sign in to comment.