public void SuiteResultXmlNodeIsFailure() { TNode suiteNode = _suiteResult.ToXml(true); Assert.AreEqual("Failed", suiteNode.Attributes["result"]); Assert.AreEqual(null, suiteNode.Attributes["label"]); Assert.AreEqual("Child", suiteNode.Attributes["site"]); TNode failureNode = suiteNode.SelectSingleNode("failure"); Assert.NotNull(failureNode, "No <failure> element found"); TNode messageNode = failureNode.SelectSingleNode("message"); Assert.NotNull(messageNode, "No <message> element found"); Assert.AreEqual(TestResult.CHILD_ERRORS_MESSAGE, messageNode.Value); TNode stacktraceNode = failureNode.SelectSingleNode("stacktrace"); Assert.Null(stacktraceNode, "Unexpected <stack-trace> element found"); Assert.AreEqual("0", suiteNode.Attributes["passed"]); Assert.AreEqual("1", suiteNode.Attributes["failed"]); Assert.AreEqual("0", suiteNode.Attributes["warnings"]); Assert.AreEqual("0", suiteNode.Attributes["skipped"]); Assert.AreEqual("0", suiteNode.Attributes["inconclusive"]); Assert.AreEqual("3", suiteNode.Attributes["asserts"]); }
public void TestResultXmlNodeIsFailure() { TNode testNode = testResult.ToXml(true); Assert.AreEqual("Failed", testNode.Attributes["result"]); Assert.AreEqual(null, testNode.Attributes["label"]); Assert.AreEqual(null, testNode.Attributes["site"]); Assert.AreEqual("1968-04-08 15:05:30Z", testNode.Attributes["start-time"]); Assert.AreEqual("1968-04-08 15:05:30Z", testNode.Attributes["end-time"]); Assert.AreEqual("0.125000", testNode.Attributes["duration"]); TNode failureNode = testNode.SelectSingleNode("failure"); Assert.NotNull(failureNode, "No <failure> element found"); TNode messageNode = failureNode.SelectSingleNode("message"); Assert.NotNull(messageNode, "No <message> element found"); Assert.AreEqual("message", messageNode.Value); TNode stacktraceNode = failureNode.SelectSingleNode("stack-trace"); Assert.NotNull(stacktraceNode, "No <stack-trace> element found"); Assert.AreEqual("stack trace", stacktraceNode.Value); }
public void SuiteResultXmlNodeIsFailure() { TNode suiteNode = _suiteResult.ToXml(true); Assert.AreEqual("Failed", suiteNode.Attributes["result"]); TNode failureNode = suiteNode.SelectSingleNode("failure"); Assert.NotNull(failureNode, "No failure element found"); TNode messageNode = failureNode.SelectSingleNode("message"); Assert.NotNull(messageNode, "No message element found"); Assert.AreEqual(TestResult.CHILD_ERRORS_MESSAGE, messageNode.Value); TNode stacktraceNode = failureNode.SelectSingleNode("stacktrace"); Assert.Null(stacktraceNode, "There should be no stacktrace"); Assert.AreEqual("5", suiteNode.Attributes["total"]); Assert.AreEqual("2", suiteNode.Attributes["passed"]); Assert.AreEqual("1", suiteNode.Attributes["failed"]); Assert.AreEqual("1", suiteNode.Attributes["warnings"]); Assert.AreEqual("0", suiteNode.Attributes["skipped"]); Assert.AreEqual("1", suiteNode.Attributes["inconclusive"]); Assert.AreEqual("6", suiteNode.Attributes["asserts"]); }
public void TestResultXml_Properties() { TNode testNode = _testResult.ToXml(true); Assert.AreEqual(TEST_DESCRIPTION, testNode.SelectSingleNode("properties/property[@name='Description']").Attributes["value"]); Assert.AreEqual(TEST_CATEGORY, testNode.SelectSingleNode("properties/property[@name='Category']").Attributes["value"]); Assert.AreEqual(TEST_PRIORITY, testNode.SelectSingleNode("properties/property[@name='Priority']").Attributes["value"]); }
public void SuiteResultXml_Properties() { TNode suiteNode = _suiteResult.ToXml(true); Assert.AreEqual(SUITE_DESCRIPTION, suiteNode.SelectSingleNode("properties/property[@name='Description']").Attributes["value"]); Assert.AreEqual(SUITE_CATEGORY, suiteNode.SelectSingleNode("properties/property[@name='Category']").Attributes["value"]); Assert.AreEqual(SUITE_LEVEL.ToString(), suiteNode.SelectSingleNode("properties/property[@name='Level']").Attributes["value"]); }
protected static void ReasonNodeExpectedValidation(TNode testNode, string reasonMessage) { TNode reason = testNode.SelectSingleNode("reason"); Assert.NotNull(reason); Assert.NotNull(reason.SelectSingleNode("message")); Assert.AreEqual(reasonMessage, reason.SelectSingleNode("message").Value); Assert.Null(reason.SelectSingleNode("stack-trace")); }
public void SuiteResultXmlNodeBasicInfo() { TNode suiteNode = suiteResult.ToXml(true); Assert.NotNull(suiteNode.Attributes["id"]); Assert.AreEqual("test-suite", suiteNode.Name); Assert.AreEqual("TestResultTests+DummySuite", suiteNode.Attributes["name"]); Assert.AreEqual("NUnit.Framework.Internal.TestResultTests+DummySuite", suiteNode.Attributes["fullname"]); Assert.AreEqual("Suite description", suiteNode.SelectSingleNode("properties/property[@name='Description']").Attributes["value"]); Assert.AreEqual("Fast", suiteNode.SelectSingleNode("properties/property[@name='Category']").Attributes["value"]); Assert.AreEqual("3", suiteNode.SelectSingleNode("properties/property[@name='Value']").Attributes["value"]); }
public void TestResultXmlNodeIsInconclusive() { TNode testNode = testResult.ToXml(true); Assert.AreEqual("Inconclusive", testNode.Attributes["result"]); Assert.IsNull(testNode.Attributes["label"]); Assert.IsNull(testNode.Attributes["site"]); TNode reason = testNode.SelectSingleNode("reason"); Assert.NotNull(reason); Assert.NotNull(reason.SelectSingleNode("message")); Assert.AreEqual("because", reason.SelectSingleNode("message").Value); Assert.Null(reason.SelectSingleNode("stack-trace")); }
public void TestResultXmlNodeIsNotRunnable() { TNode testNode = _testResult.ToXml(true); Assert.AreEqual("Failed", testNode.Attributes["result"]); Assert.AreEqual("Invalid", testNode.Attributes["label"]); Assert.AreEqual(null, testNode.Attributes["site"]); TNode failure = testNode.SelectSingleNode("failure"); Assert.NotNull(failure); Assert.NotNull(failure.SelectSingleNode("message")); Assert.AreEqual("bad test", failure.SelectSingleNode("message").Value); Assert.Null(failure.SelectSingleNode("stack-trace")); }
public void TestResultXmlNodeBasicInfo() { TNode testNode = testResult.ToXml(true); Assert.NotNull(testNode.Attributes["id"]); Assert.AreEqual("test-case", testNode.Name); Assert.AreEqual("DummyMethod", testNode.Attributes["name"]); Assert.AreEqual("NUnit.Framework.Internal.TestResultTests+DummySuite.DummyMethod", testNode.Attributes["fullname"]); Assert.AreEqual("Test description", testNode.SelectSingleNode("properties/property[@name='Description']").Attributes["value"]); Assert.AreEqual("Dubious", testNode.SelectSingleNode("properties/property[@name='Category']").Attributes["value"]); Assert.AreEqual("low", testNode.SelectSingleNode("properties/property[@name='Priority']").Attributes["value"]); Assert.AreEqual(0, testNode.SelectNodes("test-case").Count); }
public void TestResultXmlNodeIsWarning() { TNode testNode = _testResult.ToXml(true); Assert.AreEqual("Warning", testNode.Attributes["result"]); Assert.AreEqual(null, testNode.Attributes["label"]); Assert.AreEqual(null, testNode.Attributes["site"]); TNode reason = testNode.SelectSingleNode("reason"); Assert.NotNull(reason); Assert.NotNull(reason.SelectSingleNode("message")); Assert.AreEqual("Warning message", reason.SelectSingleNode("message").Value); Assert.Null(reason.SelectSingleNode("stack-trace")); }
protected static void StackTraceNodeExistsAndValueAsExpected(TNode failureNode, string expectedStackTrace) { TNode stacktraceNode = failureNode.SelectSingleNode("stack-trace"); Assert.That(stacktraceNode, Is.Not.Null, "No <stack-trace> element found"); Assert.That(stacktraceNode.Value, Is.EqualTo(expectedStackTrace)); }
protected static void MessageNodeExistsAndValueAsExpected(TNode failureNode, string expectedFailureMessage) { TNode messageNode = failureNode.SelectSingleNode("message"); Assert.That(messageNode, Is.Not.Null, "No <message> element found"); Assert.That(messageNode.Value, Is.EqualTo(expectedFailureMessage)); }
protected static TNode FailureNodeExistsAndIsNotNull(TNode testNode) { TNode failureNode = testNode.SelectSingleNode("failure"); Assert.That(failureNode, Is.Not.Null, "No <failure> element found"); return(failureNode); }
public void TestResultXmlNodeIsSuccess() { TNode testNode = testResult.ToXml(true); Assert.AreEqual("Passed", testNode.Attributes["result"]); Assert.AreEqual(null, testNode.Attributes["label"]); Assert.AreEqual(null, testNode.Attributes["site"]); Assert.AreEqual("1968-04-08 15:05:30Z", testNode.Attributes["start-time"]); Assert.AreEqual("1968-04-08 15:05:30Z", testNode.Attributes["end-time"]); Assert.AreEqual("0.125000", testNode.Attributes["duration"]); Assert.AreEqual("2", testNode.Attributes["asserts"]); TNode reason = testNode.SelectSingleNode("reason"); Assert.NotNull(reason); Assert.NotNull(reason.SelectSingleNode("message")); Assert.AreEqual("Test passed!", reason.SelectSingleNode("message").Value); Assert.Null(reason.SelectSingleNode("stack-trace")); }
public void TestResultXml_AssertionResults() { TNode assertionResults = _testResult.ToXml(true).SelectSingleNode("assertions"); if (_expectedAssertions.Count == 0) { Assert.Null(assertionResults, "No <assertions> element expected"); return; } Assert.NotNull(assertionResults, "Expected <assertions> element"); var assertionNodes = assertionResults.SelectNodes("assertion"); Assert.NotNull(assertionNodes, "Empty <assertions> element"); Assert.AreEqual(_expectedAssertions.Count, assertionNodes.Count, "Wrong number of <assertion> elements"); for (int index = 0; index < _expectedAssertions.Count; index++) { AssertionResult expectedAssertion = _expectedAssertions[index]; TNode assertionNode = assertionNodes[index]; Assert.AreEqual(expectedAssertion.Status.ToString(), assertionNode.Attributes["result"]); if (expectedAssertion.Message != null) { TNode messageNode = assertionNode.SelectSingleNode("message"); Assert.NotNull(messageNode); Assert.That(messageNode.Value, Is.EqualTo(expectedAssertion.Message)); } if (expectedAssertion.StackTrace != null) { TNode stackNode = assertionNode.SelectSingleNode("stack-trace"); Assert.NotNull(stackNode); Assert.That(stackNode.Value, Is.EqualTo(expectedAssertion.StackTrace)); } } }
public void TestResultXmlNodeEscapesInvalidXmlCharacters() { _testResult.SetResult(ResultState.Failure, "Invalid Characters: \u0001\u0008\u000b\u001f\ud800; Valid Characters: \u0009\u000a\u000d\u0020\ufffd\ud800\udc00"); TNode testNode = _testResult.ToXml(true); TNode failureNode = testNode.SelectSingleNode("failure"); Assert.That(failureNode, Is.Not.Null, "No <failure> element found"); TNode messageNode = failureNode.SelectSingleNode("message"); Assert.That(messageNode, Is.Not.Null, "No <message> element found"); Assert.That(messageNode.Value, Is.EqualTo("Invalid Characters: \\u0001\\u0008\\u000b\\u001f\\ud800; Valid Characters: \u0009\u000a\u000d\u0020\ufffd\ud800\udc00")); }
public void TestResultXmlNodeIsFailure() { TNode testNode = _testResult.ToXml(true); Assert.AreEqual("Failed", testNode.Attributes["result"]); Assert.AreEqual(null, testNode.Attributes["label"]); Assert.AreEqual(null, testNode.Attributes["site"]); TNode failureNode = testNode.SelectSingleNode("failure"); Assert.NotNull(failureNode, "No <failure> element found"); TNode messageNode = failureNode.SelectSingleNode("message"); Assert.NotNull(messageNode, "No <message> element found"); Assert.AreEqual("message", messageNode.Value); TNode stacktraceNode = failureNode.SelectSingleNode("stack-trace"); Assert.NotNull(stacktraceNode, "No <stack-trace> element found"); Assert.That(stacktraceNode.Value, Is.EqualTo(_testResult.StackTrace)); }
public void TestResultXmlNodeEscapesInvalidXmlCharacters() { if (ResultState == null) { Assert.Ignore("Test ignored because ResultState is not set"); } testResult.SetResult(ResultState, "Invalid Characters: \u0001\u0008\u000b\u001f\ud800; Valid Characters: \u0009\u000a\u000d\u0020\ufffd\ud800\udc00"); TNode testNode = testResult.ToXml(true); TNode reasonNode = testNode.SelectSingleNode(ReasonNodeName); Assert.That(reasonNode, Is.Not.Null, "No <{0}> element found", ReasonNodeName); TNode messageNode = reasonNode.SelectSingleNode("message"); Assert.That(messageNode, Is.Not.Null, "No <message> element found"); Assert.That(messageNode.Value, Is.EqualTo("Invalid Characters: \\u0001\\u0008\\u000b\\u001f\\ud800; Valid Characters: \u0009\u000a\u000d\u0020\ufffd\ud800\udc00")); }
protected static void StackTraceNodeDoesNotExist(TNode failureNode) { TNode stacktraceNode = failureNode.SelectSingleNode("stack-trace"); Assert.That(stacktraceNode, Is.Null, "<stack-trace> element found but was not expected"); }
private void CheckXmlForTest(Test test, TNode topNode, bool recursive) { Assert.NotNull(topNode); //if (test is TestSuite) //{ // Assert.That(xmlNode.Name, Is.EqualTo("test-suite")); // Assert.That(xmlNode.Attributes["type"].Value, Is.EqualTo(test.XmlElementName)); //} //else //{ // Assert.That(xmlNode.Name, Is.EqualTo("test-case")); //} Assert.That(topNode.Name, Is.EqualTo(test.XmlElementName)); Assert.That(topNode.Attributes["id"], Is.EqualTo(test.Id.ToString())); Assert.That(topNode.Attributes["name"], Is.EqualTo(test.Name)); Assert.That(topNode.Attributes["fullname"], Is.EqualTo(test.FullName)); if (test.Type != null) { Assert.NotNull(test.ClassName); Assert.That(topNode.Attributes["classname"], Is.EqualTo(test.ClassName)); } if (test is TestMethod) { Assert.NotNull(test.MethodName); Assert.That(topNode.Attributes["methodname"], Is.EqualTo(test.MethodName)); } Assert.That(topNode.Attributes["runstate"], Is.EqualTo(test.RunState.ToString())); if (test.Properties.Keys.Count > 0) { var expectedProps = new List <string>(); foreach (string key in test.Properties.Keys) { foreach (object value in test.Properties[key]) { expectedProps.Add(key + "=" + value.ToString()); } } TNode propsNode = topNode.SelectSingleNode("properties"); Assert.NotNull(propsNode); var actualProps = new List <string>(); foreach (TNode node in propsNode.ChildNodes) { string name = node.Attributes["name"]; string value = node.Attributes["value"]; actualProps.Add(name + "=" + value.ToString()); } Assert.That(actualProps, Is.EquivalentTo(expectedProps)); } if (recursive) { TestSuite suite = test as TestSuite; if (suite != null) { foreach (Test child in suite.Tests) { string xpathQuery = string.Format("{0}[@id={1}]", child.XmlElementName, child.Id); TNode childNode = topNode.SelectSingleNode(xpathQuery); Assert.NotNull(childNode, "Expected node for test with ID={0}, Name={1}", child.Id, child.Name); CheckXmlForTest(child, childNode, recursive); } } } }
protected static void MessageNodeDoesNotExist(TNode failureNode) { TNode messageNode = failureNode.SelectSingleNode("message"); Assert.That(messageNode, Is.Null, "<message> element found but no such node was expected"); }
protected static void NoReasonNodeExpectedValidation(TNode testNode) { TNode reason = testNode.SelectSingleNode("reason"); Assert.IsNull(reason, "This test expects no reason element to be present in the XML representation."); }
private static string GetSkipReason(TNode result) { var propNode = result.SelectSingleNode(string.Format("properties/property[@name='{0}']", PropertyNames.SkipReason)); return propNode == null ? null : propNode.Attributes["value"]; }
private static string GetSkipReason(TNode result) { var propNode = result.SelectSingleNode(string.Format("properties/property[@name='{0}']", PropertyNames.SkipReason)); return(propNode == null ? null : propNode.Attributes["value"]); }
public void SuiteResultXml_AssertionResults() { TNode suiteNode = _suiteResult.ToXml(true); Assert.Null(suiteNode.SelectSingleNode("assertions")); }