public void MethodFormat_Full_ShouldIncludeNamespaceAndClass() { DotnetTestFixture.Execute("method-full-test-results.xml;MethodFormat=Full"); string resultsFile = Path.Combine(DotnetTestFixture.RootDirectory, "method-full-test-results.xml"); XDocument resultsXml = XDocument.Load(resultsFile); var testcases = resultsXml.XPathSelectElements("/testsuites/testsuite") .Descendants() .Where(x => x.Name.LocalName == "testcase") .ToList(); foreach (var testcase in testcases) { var parsedName = new TestCaseNameParser().Parse(testcase.Attribute("name").Value); // We expect the full name would be the class name plus the parsed method var expectedFullName = parsedName.Namespace + "." + parsedName.Type + "." + parsedName.Method; // If the name is parsable into two pieces, then we have at least a two piece name Assert.AreNotEqual(parsedName.Type, TestCaseNameParser.TestCaseParserUnknownType); Assert.AreEqual(expectedFullName, testcase.Attribute("name").Value); } Assert.IsTrue(new JunitXmlValidator().IsValid(resultsXml)); }
public void FailureBodyFormat_Verbose_ShouldContainConsoleOut() { DotnetTestFixture.Execute("failure-verbose-test-results.xml;FailureBodyFormat=Verbose"); string resultsFile = Path.Combine(DotnetTestFixture.RootDirectory, "failure-verbose-test-results.xml"); XDocument resultsXml = XDocument.Load(resultsFile); var failures = resultsXml.XPathSelectElements("/testsuites/testsuite") .Descendants() .Where(x => x.Name.LocalName == "failure") .ToList(); Assert.AreEqual(1, failures.Count(x => x.Value.Contains("{EEEE1DA6-6296-4486-BDA5-A50A19672F0F}"))); Assert.AreEqual(1, failures.Count(x => x.Value.Contains("{C33FF4B5-75E1-4882-B968-DF9608BFE7C2}"))); }
public static void SuiteInitialize(TestContext context) { DotnetTestFixture.RootDirectory = Path.GetFullPath( Path.Combine( Environment.CurrentDirectory, "..", "..", "..", "..", "assets", "JUnit.Xml.TestLogger.NetCore.Tests")); DotnetTestFixture.TestAssemblyName = "JUnit.Xml.TestLogger.NetCore.Tests.dll"; DotnetTestFixture.Execute("test-results.xml", "./artifacts"); }
public void MethodFormat_Default_ShouldBeOnlyTheMethod() { DotnetTestFixture.Execute("method-default-test-results.xml;MethodFormat=Default"); string resultsFile = Path.Combine(DotnetTestFixture.RootDirectory, "method-default-test-results.xml"); XDocument resultsXml = XDocument.Load(resultsFile); var testcases = resultsXml.XPathSelectElements("/testsuites/testsuite") .Descendants() .Where(x => x.Name.LocalName == "testcase") .ToList(); foreach (var testcase in testcases) { var parsedName = TestCaseNameParser.Parse(testcase.Attribute("name").Value); // A method name only will not be parsable into two pieces Assert.AreEqual(parsedName.TypeName, TestCaseNameParser.TestCaseParserUnknownType); } }
public void MethodFormat_Class_ShouldIncludeClass() { DotnetTestFixture.Execute("method-class-test-results.xml;MethodFormat=Class"); string resultsFile = Path.Combine(DotnetTestFixture.RootDirectory, "method-class-test-results.xml"); XDocument resultsXml = XDocument.Load(resultsFile); var testcases = resultsXml.XPathSelectElements("/testsuites/testsuite") .Descendants() .Where(x => x.Name.LocalName == "testcase") .ToList(); foreach (var testcase in testcases) { var parsedName = TestCaseNameParser.Parse(testcase.Attribute("name").Value); // If the name is parsable into two pieces, then we have a two piece name and // consider that to be a passing result. Assert.AreNotEqual(parsedName.TypeName, TestCaseNameParser.TestCaseParserUnknownType); } }
public void FailureBodyFormat_Verbose_ShouldStartWithMessage() { DotnetTestFixture.Execute("failure-verbose-test-results.xml;FailureBodyFormat=Verbose"); string resultsFile = Path.Combine(DotnetTestFixture.RootDirectory, "failure-verbose-test-results.xml"); XDocument resultsXml = XDocument.Load(resultsFile); var failures = resultsXml.XPathSelectElements("/testsuites/testsuite") .Descendants() .Where(x => x.Name.LocalName == "failure") .ToList(); foreach (var failure in failures) { // Strip new line and carrige return. These may be inconsistent depending on environment settings var message = failure.Attribute("message").Value.Replace("\r", string.Empty).Replace("\n", string.Empty); var body = failure.Value.Replace("\r", string.Empty).Replace("\n", string.Empty); Assert.IsTrue(body.Trim().StartsWith(message.Trim())); } }
public static void SuiteInitialize(TestContext context) { DotnetTestFixture.Execute("test-results.xml"); }