Пример #1
0
    public void ClassFailed()
    {
        TestableTdNetLogger logger = TestableTdNetLogger.Create();

        bool result = logger.ClassFailed("TdNetLoggerTests", null, "Message", "StackTrace");

        TestResult summary = logger.Listener.TestFinished_Summaries[0];

        Assert.Equal(typeof(TdNetLoggerTests), summary.FixtureType);
        Assert.Equal("Fixture TdNetLoggerTests", summary.Name);
        Assert.Equal(1, summary.TotalTests);
        Assert.Equal(TestState.Failed, summary.State);
        Assert.Equal("Message", summary.Message);
        Assert.Equal("StackTrace", summary.StackTrace);
        Assert.True(result);
    }
Пример #2
0
    public void TestPassed()
    {
        TestableTdNetLogger logger = TestableTdNetLogger.Create();

        logger.TestPassed("name", "TdNetLoggerTests", "TestPassed", 1.234, null);

        TestResult summary = logger.Listener.TestFinished_Summaries[0];

        Assert.Equal(typeof(TdNetLoggerTests), summary.FixtureType);
        Assert.Equal(typeof(TdNetLoggerTests).GetMethod("TestPassed"), summary.Method);
        Assert.Equal("name", summary.Name);
        Assert.Equal(1, summary.TotalTests);
        Assert.Equal(TestState.Passed, summary.State);
        Assert.Equal(new TimeSpan(12340), summary.TimeSpan);
        Assert.Null(summary.Message);
        Assert.Null(summary.StackTrace);
    }
Пример #3
0
        public bool ClassFailed(string className, string exceptionType, string message, string stackTrace)
        {
            Type type = assembly.GetType(className);

            TestResult testResult =
                new TestResult
                    {
                        FixtureType = type,
                        Name = ("Fixture " + type.FullName),
                        TotalTests = 1,
                        State = TestState.Failed,
                        Message = message,
                        StackTrace = stackTrace
                    };

            if (listener != null)
                listener.TestFinished(testResult);

            return true;
        }
Пример #4
0
            void processTest(XmlElement element, string report, bool isTestCase)
            {
                var testResult = new TDF.TestResult();

                testResult.TotalTests     = TotalTests;
                testResult.TestRunnerName = testRunnerName;

                testResult.Name = element.GetAttribute("fullname");

                var messageElement = element.SelectSingleNode("//message");

                if (messageElement != null)
                {
                    var text = trimNewLine(messageElement.InnerText);
                    testResult.Message = text;
                }

                var stackTraceElement = element.SelectSingleNode("//stack-trace");

                if (stackTraceElement != null)
                {
                    testResult.StackTrace = stackTraceElement.InnerText;
                }

                var result = element.GetAttribute("result");

                TDF.TestState state;
                switch (result)
                {
                case "Failed":
                    state        = TDF.TestState.Failed;
                    TestRunState = TDF.TestRunState.Failure;
                    break;

                case "Passed":
                    state = TDF.TestState.Passed;
                    break;

                case "Skipped":
                case "Inconclusive":
                    state = TDF.TestState.Ignored;
                    break;

                default:
                    state = TDF.TestState.Failed;
                    testListener.WriteLine("Unknown 'result': " + result + "\n" + report, TDF.Category.Error);
                    break;
                }

                testResult.State = state;

                if (isTestCase)
                {
                    testListener.TestFinished(testResult);
                    return;
                }

                // Fake failed test when fixture contains stack trace info.
                if (!isTestCase && testResult.StackTrace != null)
                {
                    testListener.TestFinished(testResult);
                    return;
                }
            }