Beispiel #1
0
        public static MSVST4U_UnitTestResult ExecuteTest(IExecutorWrapper executor, Guid runId, MSVST4U_UnitTestElement testElement)
        {
            var logger = new XUnitTestRunner(runId, testElement);
            var runner = new TestRunner(executor, logger);

            string fclassname = MSVST4U_Access.GetFullyQualifiedClassName(testElement);
            if (fclassname == null) throw new NotImplementedException("xUnit runner does not currently know how to extract a ClassName from test type: " + (testElement == null ? "(null)" : testElement.GetType().FullName));

            // The testElement is the original UnitTestElement, so the result is the original UnitTestResult.
            // However, due to the nature of some unit test types, we could have gathered many results, and must
            // now group them together.

            runner.RunTest(fclassname, testElement.Name);

            MSVST4U_UnitTestResult result;

            if (logger._isTheory)
            {
                Debug.Assert(logger._results.Count > 0, "Expected at least one result for Theory test " + testElement.Name + ": " + logger._results.Count);

                MSVST4U_UnitTestResult[] innerResults = logger._results.ToArray();
                TestOutcome outcome = TestOutcomeHelper.GetAggregationOutcome(innerResults);

                // for a Theory test (a DataDriven test in the original VS nomenclature), the logger gathered
                // multiple responses and they should be packed up together in a "TestAggregateResult". Actually,
                // a original UnitTestResult already implements that and it is available as a constructor overload.
                result = MSVST4U_Access.New_MSVST4U_UnitTestResult_DataDriven(runId, testElement, outcome, null, innerResults);
            }
            else
            {
                Debug.Assert(logger._results.Count == 1, "Expected one result for non-Theory test " + testElement.Name + ": " + logger._results.Count);

                // for a Fact test (a NotDataDriven test in the original VS nomenclature), the logger gathered
                // a single response; it is completely valid to simply return it
                result = logger._results[0];
            }

            return result;
        }
Beispiel #2
0
 public static string GetFullyQualifiedClassName(MSVST4U_UnitTestElement testElement)
 {
     return MSVST4U_Tunnels.TS_FullyQualifiedClassName(testElement);
 }