Represents the result of running a test suite
Inheritance: NUnit.Framework.Internal.TestResult
Esempio n. 1
0
		public void SetUp()
		{
            test = new TestMethod(typeof(DummySuite).GetMethod("DummyMethod"));
            test.Properties.Set(PropertyNames.Description, "Test description");
            test.Properties.Add(PropertyNames.Category, "Dubious");
            test.Properties.Set("Priority", "low");
			testResult = (TestCaseResult)test.MakeTestResult();

            TestSuite suite = new TestSuite(typeof(DummySuite));
            suite.Properties.Set(PropertyNames.Description, "Suite description");
            suite.Properties.Add(PropertyNames.Category, "Fast");
            suite.Properties.Add("Value", 3);
            suiteResult = (TestSuiteResult)suite.MakeTestResult();

            SimulateTestRun();
        }
Esempio n. 2
0
        public void SetUp()
        {
            expectedDuration = 0.125;
            expectedStart = new DateTime(1968, 4, 8, 15, 05, 30, 250, DateTimeKind.Utc);
            expectedEnd = expectedStart.AddSeconds(expectedDuration);

            test = new TestMethod(new MethodWrapper(typeof(DummySuite), "DummyMethod"));
            test.Properties.Set(PropertyNames.Description, "Test description");
            test.Properties.Add(PropertyNames.Category, "Dubious");
            test.Properties.Set("Priority", "low");
            testResult = test.MakeTestResult();

            TestSuite suite = new TestSuite(typeof(DummySuite));
            suite.Properties.Set(PropertyNames.Description, "Suite description");
            suite.Properties.Add(PropertyNames.Category, "Fast");
            suite.Properties.Add("Value", 3);
            suiteResult = (TestSuiteResult)suite.MakeTestResult();

            SimulateTestRun();
        }
Esempio n. 3
0
        private static string GenerateExpectedXml(TestResult result)
        {
            StringBuilder   expected    = new StringBuilder();
            TestSuiteResult suiteResult = result as TestSuiteResult;

            if (suiteResult != null)
            {
                expected.Append("<test-suite type=" + Quoted("TestSuite"));
            }
            else
            {
                expected.Append("<test-case");
            }

            expected.Append(" id=" + Quoted(result.Test.Id));
            expected.Append(" name=" + Quoted(result.Name));
            expected.Append(" fullname=" + Quoted(result.FullName));

            if (suiteResult != null)
            {
                expected.Append(" testcasecount=" + Quoted(result.Test.TestCaseCount));
            }

            expected.Append(" result=" + Quoted(result.ResultState.Status));
            if (result.ResultState.Label != null && result.ResultState.Label != "")
            {
                expected.Append(" label=" + Quoted(result.ResultState.Label));
            }

            expected.Append(" time=" + Quoted(result.Time.ToString("0.000", System.Globalization.CultureInfo.InvariantCulture)));

            if (suiteResult != null)
            {
                ResultSummary summary = new ResultSummary(suiteResult);
                expected.Append(" total=" + Quoted(suiteResult.PassCount + suiteResult.FailCount + suiteResult.InconclusiveCount + suiteResult.SkipCount));
                expected.Append(" passed=" + Quoted(suiteResult.PassCount));
                expected.Append(" failed=" + Quoted(suiteResult.FailCount));
                expected.Append(" inconclusive=" + Quoted(suiteResult.InconclusiveCount));
                expected.Append(" skipped=" + Quoted(suiteResult.SkipCount));
            }

            expected.Append(" asserts=" + Quoted(result.AssertCount) + ">");

            if (result.Test.Properties.Count > 0)
            {
                expected.Append("<properties>");
                foreach (string key in result.Test.Properties.Keys)
                {
                    foreach (object value in result.Test.Properties[key])
                    {
                        expected.Append("<property name=" + Quoted(key) + " value=" + Quoted(value) + " />");
                    }
                }
                expected.Append("</properties>");
            }

            if (result.ResultState.Status == TestStatus.Failed)
            {
                expected.Append("<failure>");
                if (result.Message != null)
                {
                    expected.Append("<message>" + Escape(result.Message) + "</message>");
                }
#if !NETCF_1_0
                if (result.StackTrace != null)
                {
                    expected.Append("<stack-trace>" + Escape(result.StackTrace) + "</stack-trace>");
                }
#endif
                expected.Append("</failure>");
            }
            else if (result.Message != null)
            {
                expected.Append("<reason><message>" + Escape(result.Message) + "</message></reason>");
            }

            if (suiteResult != null)
            {
                foreach (TestResult childResult in suiteResult.Children)
                {
                    expected.Append(GenerateExpectedXml(childResult));
                }

                expected.Append("</test-suite>");
            }
            else
            {
                expected.Append("</test-case>");
            }

            return(expected.ToString());
        }