コード例 #1
0
            // Is this TestCase a dynamic element? One that is created at runtime, and therefore not
            // included in the current session. We do this by looking to see if it's a theory, which
            // is most frequently a dynamic element, or if it's a method belonging to a class, but
            // not known to that class (each class task keeps a track of all discovered test methods,
            // so we can tell if it's something we didn't know about, or something we didn't want to
            // run)
            private bool IsDynamicMethod(ITestCase testCase)
            {
                var typeName    = testCase.TestMethod.TestClass.Class.Name;
                var methodName  = testCase.TestMethod.Method.Name;
                var displayName = testCase.DisplayName ?? MakeFallbackDisplayName(typeName, methodName);

                var classTaskWrapper = runContext.GetRemoteTask(typeName);

                if (classTaskWrapper == null)
                {
                    Logger.LogVerbose(
                        " Test case does not belong to a known class. Cannot be a dynamic test of a requested class. {0} - {1}",
                        testCase.TestMethod.TestClass.Class.Name, testCase.Format());
                    return(false);
                }

                var classTask = (XunitTestClassTask)classTaskWrapper.RemoteTask;

                if (IsTheory(displayName, typeName, methodName))
                {
                    var isDynamicTheory = !classTask.IsKnownMethod(displayName.Replace(typeName + ".", string.Empty));
                    Logger.LogVerbose(" Test case is a theory, {0} to a requested method: {1}",
                                      isDynamicTheory ? "belongs" : "does NOT belong", testCase.Format());
                    return(isDynamicTheory);
                }

                var isDynamicMethod = !classTask.IsKnownMethod(methodName);

                Logger.LogVerbose(" Test case is {0} dynamic method: {1}", isDynamicMethod ? "a previously unseen" : "NOT a",
                                  testCase.Format());
                return(isDynamicMethod);
            }
コード例 #2
0
        protected override bool Visit(ITestClassStarting testClassStarting)
        {
            var taskInfo = context.GetRemoteTask(testClassStarting);

            taskInfo.Starting();
            return(context.ShouldContinue);
        }