Esempio n. 1
0
 public static void SerializeToFile(TestStepResult testStepResult, string filePath)
 {
     TestArtifact.SerializeToFile(testStepResult, filePath);
 }
Esempio n. 2
0
        public TestCaseResult Execute()
        {
            string currentUser = Thread.CurrentThread.Name;

            FireExecutionBeginEvent(this, new TestCaseBeginExecutionArgs(currentUser));

            CheckForPossibleBreakpointMode();

            TestCaseResult testCaseResult = new TestCaseResult();

            testCaseResult.SetReferenceID(SystemID);
            testCaseResult.SetVirtualUser(currentUser);

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

            AddRuntimeTestPropertiesToTestProperties();

            _testClassDictionary = new Dictionary <int, TestClassBase>();

            List <TestScriptObject> activeTestSteps = getActiveChildren();

            testCaseResult.SetStartTime(DateTime.Now);

            if (activeTestSteps.Count > 0)
            {
                // Iterate through each test step.
                foreach (TestStep testStep in activeTestSteps)
                {
                    var explanation = string.Empty;

                    // Determine is test steup should be run.  If so, execute.
                    if (determineExecutionStatus(testStep, testCaseResult, out explanation))
                    {
                        var testStepResult = testStep.Execute(_testClassDictionary);

                        testCaseResult.AddResult(testStepResult);
                        testCaseResult.IncrementCounter(testStepResult.TestVerdict);

                        if (testStepResult.TestVerdict != TestVerdict.Pass)
                        {
                            testCaseResult.FinalizeVerdict();
                        }
                    }
                    else
                    {
                        var testStepResult = new TestStepResult(TestVerdict.DidNotExecute, explanation);
                        testCaseResult.AddResult(testStepResult);
                        testCaseResult.IncrementCounter(testStepResult.TestVerdict);
                        testStep.FireExecutionCompleteEvent(testStep, testStepResult);
                    }
                }
            }
            else
            {
                testCaseResult.SetTestVerdict(TestVerdict.DidNotExecute);
                testCaseResult.SetTestMessage("The test case is set to \"Active\", however it does not contain active test steps.");
            }

            testCaseResult.SetEndTime(DateTime.Now);
            testCaseResult.FinalizeVerdict();

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

            FireExecutionCompleteEvent(this, testCaseResult);

            return(testCaseResult);
        }