コード例 #1
0
        /// <summary>
        /// Intiailize the TestSuite for running a specific variation, e.g. parse arguments
        /// and set the proper properties.
        /// </summary>
        private void InitializeVariation()
        {
            GlobalLog.LogStatus("Starting Setup Stage");
            CurrentSuite.ProcessArgs(CurrentVariation.Parameters);

            if (CurrentVariation.TestCase.SetupMethod != null)
            {
                Invoke(CurrentVariation.TestCase.SetupMethod);
            }
        }
コード例 #2
0
 /// <summary>
 /// Run test with the current setup.
 /// </summary>
 protected virtual void RunVariation()
 {
     // Deprecated: this is for backwards compat, eventually should remove...
     if (CurrentVariation.TestCase.TestMethod == null)
     {
         Invoke(CurrentSuite.GetType().GetMethod("RunTestCase", BindingFlags.Instance | BindingFlags.NonPublic));
     }
     else
     {
         Invoke(CurrentVariation.TestCase.TestMethod);
     }
 }
コード例 #3
0
        private void HandleResult(TestResultException e)
        {
            if (e is TestPassedException)
            {
                SetVariationPassed(e.Message);

                /*
                 * Allow all remaining context tasks to be processed before logging PASSED.  This will
                 * hopefully catch exceptions that might be thrown asynchronously.
                 */
                CurrentSuite.BeginInvoke(new DispatcherOperationCallback(LogAndShutdownVariation), null, DispatcherPriority.SystemIdle);
            }
            else if (e is TestFailedException)
            {
                SetVariationFailed(e);
                // Shutdown immediately (do not process further context tasks).
                LogAndShutdownVariation(null);
            }
        }
コード例 #4
0
        /// <summary>
        /// Handle any kind of exception and convert it into a pass or fail state for the
        /// test.
        ///
        /// If FAIL: fail and shutdown test immediately.
        /// If PASS: process remaining context tasks and then pass and shutdown.
        /// </summary>
        /// <param name="e"></param>
        private void HandleException(Exception e)
        {
            // Ignore future exceptions if the test has already been logged as a failure
            // because this is probably a side-effect of the original failure.
            if (CurrentVariation.Result == VariationResult.Failed)
            {
                return;
            }

            if (e is TestPassedException)
            {
                SetVariationPassed(e.Message);

                /*
                 * Allow all remaining context tasks to be processed before logging PASSED.  This will
                 * hopefully catch exceptions that might be thrown asynchronously.
                 */
                CurrentSuite.BeginInvoke(new DispatcherOperationCallback(LogAndShutdownVariation), null, DispatcherPriority.SystemIdle);
            }
            else
            {
                if (e is TestFailedException)
                {
                    SetVariationFailed(e);
                }
                else
                {
                    string message = e.ToString();

                    // If this exception was thrown from Proxy framework then append the proxy stack trace
                    // for debugging.
                    if (e.Data.Contains("ProxyStackTrace"))
                    {
                        message = e.Message + ":\n" + e.Data["ProxyStackTrace"] + "\n" + e.StackTrace;
                    }
                    SetVariationFailed("Unexpected exception was thrown:\n" + e.GetType().FullName + " - " + message);
                }

                // Shutdown immediately (do not process further context tasks).
                LogAndShutdownVariation(null);
            }
        }