예제 #1
0
 public TestSuite(string title, string filePath, TestSuite testSuite)
     : base(title, testSuite)
 {
     _filePath          = filePath;
     _testPreprocessor  = new TestPreprocessor(this);
     _testPostProcessor = new TestPostprocessor(this);
 }
예제 #2
0
 public TestSuite(TestSuite originalTestSuite, string filePath, TestSuite parent)
     : base(originalTestSuite, parent)
 {
     _filePath          = filePath;
     _project           = TestUtils.SafeCopyString(originalTestSuite._project);
     _testPreprocessor  = new TestPreprocessor(originalTestSuite._testPreprocessor);
     _testPostProcessor = new TestPostprocessor(originalTestSuite.TestPostprocessor);
 }
예제 #3
0
 public TestPostprocessor(TestPostprocessor originalTestPostprocessor)
     : base(originalTestPostprocessor)
 {
 }
예제 #4
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);
        }