Created
July 11, 2019 23:18
-
-
Save akramarev/aac41cecc9a37c7b5965b16b426c0dd2 to your computer and use it in GitHub Desktop.
[Nunit] Nunit Short Path Finder App. Works in linqpad also.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
XDocument xDocument; | |
using (XmlReader xr = XmlReader.Create(@"c:\Users\akramarev\Downloads\TestResultSet.xml")) | |
{ | |
xDocument = XDocument.Load(xr); | |
} | |
var testElements = xDocument.XPathSelectElements(@"//test-suite[@type=""TestFixture""]") | |
.Select(e => new TestElement(e)); | |
PrintOutTestCases(testElements); | |
} | |
private static void PrintOutTestCases(IEnumerable<TestElement> testElements, int level = 0) | |
{ | |
foreach (var testElement in testElements.OrderByDescending(c => c.Time).Take(10)) | |
{ | |
Console.WriteLine($"{new String(' ', level)}{testElement.Time} {testElement.Name}"); | |
if (testElement.SuiteType != null) | |
{ | |
var testCases = testElement.Element.XPathSelectElements(@"./results/test-suite | ./results/test-case") | |
.Select(e => new TestElement(e)); | |
PrintOutTestCases(testCases, level + 2); | |
} | |
} | |
} | |
public class TestElement | |
{ | |
public string Name { get; set; } | |
public double Time { get; set; } | |
public string SuiteType { get; set; } | |
public XElement Element { get; set; } | |
public TestElement(XElement e) | |
{ | |
Name = e.Attribute("name")?.Value; | |
Time = Convert.ToDouble(e.Attribute("time")?.Value); | |
SuiteType = e.Attribute("type")?.Value; | |
Element = e; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment