virtual internal TestProcessorResult Execute()
        {
            TestProcessorResult result = new TestProcessorResult();

            TestAssert.IsTrue(TestAutomationDefinition.IsCompleted(),
                              "The test suite's processor is \"Active\", however its automation definition is incomplete.");

            var resultStruct = TestAutomationDefinition.Invoke(null);

            result.SetReferenceID(SystemID);
            result.SetVirtualUser(Thread.CurrentThread.Name);
            result.SetStartTime(resultStruct.StartTime);
            result.SetEndTime(resultStruct.EndTime);
            result.SetTestVerdict(resultStruct.TestVerdict);
            result.SetTestMessage(resultStruct.TestMessage);
            result.SetTestChecks(resultStruct.TestChecks);
            result.SetTestWarnings(resultStruct.TestWarnings);

            return(result);
        }
 internal void SetTestPostprocessorResult(TestProcessorResult result)
 {
     _postProcessorResult = result;
 }
 internal void SetTestPreprocessorResult(TestProcessorResult result)
 {
     _preProcessorResult = result;
 }
Esempio n. 4
0
 private static void fireTestPreprocessorComplete(TestSuite testSuite, TestProcessorResult testProcessorResult)
 {
     OnTestPreprocessorComplete?.Invoke(testSuite, testProcessorResult);
 }
Esempio n. 5
0
        public TestSuiteResult Execute(List <TestCase> discreteTestCases)
        {
            string virtualUser = Thread.CurrentThread.Name;

            FireExecutionBeginEvent(this, new TestSuiteBeginExecutionArgs(virtualUser));

            CheckForPossibleBreakpointMode();

            _qualifiedTestCases = discreteTestCases;

            TestSuiteResult testSuiteResult = new TestSuiteResult();

            testSuiteResult.SetReferenceID(SystemID);
            testSuiteResult.SetVirtualUser(virtualUser);

            // Save copy of test property collection for restoration later (maintains scope)
            TestPropertyCollection savedTestPropertyCollection = new TestPropertyCollection(Core.TestProperties.TestPropertyCollection);

            AddRuntimeTestPropertiesToTestProperties();

            List <TestScriptObject> activeTestScriptObjects = getActiveChildren();

            testSuiteResult.SetStartTime(DateTime.Now);

            if (activeTestScriptObjects.Count > 0)
            {
                // Execute pre-processor
                TestProcessorResult processorResult = new TestProcessorResult();

                if (TestPreprocessor.Status == Core.Status.Active)
                {
                    fireTestPreprocessorBegin(this, new TestProcessorBeginExecutionArgs(virtualUser));

                    processorResult = TestPreprocessor.Execute();

                    fireTestPreprocessorComplete(this, processorResult);

                    //Update test suite result.
                    testSuiteResult.SetTestPreprocessorResult(processorResult);
                }

                if ((processorResult.TestVerdict != TestVerdict.Fail && processorResult.TestVerdict != TestVerdict.Error) ||
                    TestPreprocessor.OnFailure != OnFailure.Stop)
                {
                    // Iterate through suites test script objects
                    foreach (TestScriptObject testScriptObject in TestScriptObjects)
                    {
                        // Only execute Active objects.
                        if (testScriptObject.Status == Core.Status.Active)
                        {
                            if (testScriptObject is TestCase)
                            {
                                TestCase testCase = testScriptObject as TestCase;

                                if (isQualifiedTestCase(testCase))
                                {
                                    var testScriptResult = testCase.Execute();
                                    testSuiteResult.IncrementCounter(testScriptResult.TestVerdict);
                                    testSuiteResult.AddResult(testScriptResult);
                                }
                            }
                            else if (testScriptObject is TestSuite)
                            {
                                TestSuite childSuite       = testScriptObject as TestSuite;
                                var       testScriptResult = childSuite.Execute(discreteTestCases);
                                testSuiteResult.IncrementCounters(testScriptResult);
                                testSuiteResult.AddResult(testScriptResult);
                            }
                        }
                    }
                }
                else
                {
                    if (!TestPreprocessor.IgnoreResult)
                    {
                        testSuiteResult.SetTestVerdict(processorResult.TestVerdict);
                        testSuiteResult.SetTestMessage("The test pre-processor failed, test suite execution stopped per setting.");
                    }
                    else
                    {
                        testSuiteResult.SetTestMessage("The test pre-processor failure ignored per setting.");
                    }
                }

                // Execute post-processor
                if (TestPostprocessor.Status == Core.Status.Active)
                {
                    fireTestPostprocessorBegin(this, new TestProcessorBeginExecutionArgs(virtualUser));

                    processorResult = TestPostprocessor.Execute();

                    fireTestPostprocessorComplete(this, processorResult);

                    if (!TestPostprocessor.IgnoreResult)
                    {
                        //Update test suite result.
                        testSuiteResult.SetTestPostprocessorResult(processorResult);
                    }
                }
            }
            else
            {
                // testSuiteResult.SetTestVerdict(TestVerdict.DidNotExecute);
                testSuiteResult.SetTestMessage("The test suite is set to \"Active\", however it does not contain any active test cases or suites.");
            }

            testSuiteResult.SetEndTime(DateTime.Now);

            testSuiteResult.FinalizeVerdict();

            // Restore preserved test property collection.
            Core.TestProperties.SetTestPropertyCollection(savedTestPropertyCollection);

            FireExecutionCompleteEvent(this, testSuiteResult);

            return(testSuiteResult);
        }