コード例 #1
0
ファイル: TestAssemblyBuilder.cs プロジェクト: JoB70/xunit
        /// <summary>
        /// Creates a <see cref="TestAssembly"/> which is a complete object model over
        /// the tests inside of instance of <see cref="IExecutorWrapper"/>.
        /// </summary>
        /// <param name="executorWrapper">The executor wrapper</param>
        /// <returns>The fully populated object model</returns>
        public static TestAssembly Build(IExecutorWrapper executorWrapper)
        {
            Guard.ArgumentNotNull("executorWrapper", executorWrapper);

            List<TestClass> classes = new List<TestClass>();

            foreach (XmlNode classNode in executorWrapper.EnumerateTests().SelectNodes("//class"))
            {
                List<TestMethod> methods = new List<TestMethod>();
                string typeName = classNode.Attributes["name"].Value;

                foreach (XmlNode testNode in classNode.SelectNodes("method"))
                {
                    string methodName = testNode.Attributes["method"].Value;
                    string displayName = null;
                    string skipReason = null;

                    if (testNode.Attributes["name"] != null)
                        displayName = testNode.Attributes["name"].Value;
                    if (testNode.Attributes["skip"] != null)
                        skipReason = testNode.Attributes["skip"].Value;

                    var traits = new MultiValueDictionary<string, string>();
                    foreach (XmlNode traitNode in testNode.SelectNodes("traits/trait"))
                        traits.AddValue(traitNode.Attributes["name"].Value,
                                        traitNode.Attributes["value"].Value);

                    TestMethod testMethod = new TestMethod(methodName,
                                                           displayName ?? typeName + "." + methodName,
                                                           traits);

                    methods.Add(testMethod);

                    if (!String.IsNullOrEmpty(skipReason))
                        testMethod.RunResults.Add(new TestSkippedResult(testMethod.DisplayName, skipReason));
                }

                classes.Add(new TestClass(typeName, methods));
            }

            return new TestAssembly(executorWrapper, classes);
        }
コード例 #2
0
ファイル: MockAssembly.cs プロジェクト: nulltoken/xunit
 public bool TestStart(TestMethod testMethod)
 {
     return true;
 }
コード例 #3
0
ファイル: MockAssembly.cs プロジェクト: nulltoken/xunit
 public bool TestFinished(TestMethod testMethod)
 {
     return true;
 }
コード例 #4
0
        private void DoProcessTest(TestMethod testMethod)
        {
            var lastRunResult = testMethod.RunResults.Last();

            if (lastRunResult is TestPassedResult)
                TestPassed(lastRunResult as TestPassedResult);
            else if (lastRunResult is TestFailedResult)
                TestFailed(lastRunResult as TestFailedResult);
            else
                TestSkipped(lastRunResult as TestSkippedResult);
        }
コード例 #5
0
 public bool TestStart(TestMethod testMethod)
 {
     return !_isCancelRequested;
 }
コード例 #6
0
 public bool TestFinished(TestMethod testMethod)
 {
     Application.Current.Dispatcher.BeginInvoke((Action)(() => DoProcessTest(testMethod)));
     return !_isCancelRequested;
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: mattwarren/LinqToMemory
 public bool TestStart(TestMethod testMethod)
 {
     Console.WriteLine("{0,4}: {1}", ++index, testMethod.DisplayName);
     return true;
 }
コード例 #8
0
        public virtual bool TestFinished(TestMethod testMethod)
        {
            var result = testMethod.RunResults.Last();

            var passedResult = result as TestPassedResult;
            if (passedResult != null && _displaySuccess)
            {
                TestPassed(passedResult);
            }
            else
            {
                var failedResult = result as TestFailedResult;
                if (failedResult != null)
                {
                    TestFailed(testMethod, failedResult);
                }
                else
                {
                    var skippedResult = result as TestSkippedResult;
                    if (skippedResult != null)
                    {
                        TestSkipped(testMethod, skippedResult);
                    }
                }
            }

            Console.WriteLine("Tests complete: {0} of {1}".DarkGrey(), ++TotalTests, _testMethodCount);
            return true;
        }
コード例 #9
0
 protected virtual void TestSkipped(TestMethod testMethod, TestSkippedResult result)
 {
     Console.WriteLine("[SKIPPED] : {0} ".Yellow(), result.DisplayName);
     Console.WriteLine(Indent(result.Reason));
 }
コード例 #10
0
        protected virtual void TestFailed(TestMethod testMethod, TestFailedResult result)
        {
            Console.WriteLine("[FAILED] : {0} ".Red(), result.DisplayName);

            Console.WriteLine(Indent(result.ExceptionMessage));

            if (result.ExceptionStackTrace == null || !_displayFailureStack)
            {
                return;
            }

            Console.WriteLine(Indent("Stack Trace:").DarkGrey());
            Console.WriteLine(Indent(StackFrameTransformer.TransformStack(result.ExceptionStackTrace)).DarkGrey());
        }
コード例 #11
0
 public virtual bool TestStart(TestMethod testMethod)
 {
     return true;
 }
コード例 #12
0
 public bool TestFinished(TestMethod testMethod)
 {
     Console.WriteLine("{0} :: {1}\n", testMethod.RunStatus, testMethod.MethodName);
     return true;
 }
コード例 #13
0
ファイル: TestAssembly.cs プロジェクト: johnkg/xunit
 public bool TestStart(TestMethod testMethod)
 {
     return innerCallback.TestStart(testMethod);
 }
コード例 #14
0
ファイル: TestAssembly.cs プロジェクト: johnkg/xunit
            public bool TestFinished(TestMethod testMethod)
            {
                if (testMethod == null)
                    return false;

                ++Total;

                var lastRunResult = testMethod.RunResults[testMethod.RunResults.Count - 1];

                if (lastRunResult is TestFailedResult)
                    ++Failed;
                if (lastRunResult is TestSkippedResult)
                    ++Skipped;

                Time += lastRunResult.Duration;

                return innerCallback.TestFinished(testMethod);
            }
コード例 #15
0
 public bool TestStart(TestMethod testMethod)
 {
     return(innerCallback.TestStart(testMethod));
 }