Beispiel #1
0
 void Run()
 {
     Begin();
     try
     {
         if (!Ignore)
         {
             bool setupFailed = false;
             if (StartUpMethod != null)
             {
                 try
                 {
                     StartUpMethod.Invoke(Fixture.Instance, null);
                 }
                 catch (TargetInvocationException tie)
                 {
                     Exception exp = tie.InnerException;
                     Result.Status = TestStatus.Untested;
                     Result.Message.AppendLine("Test set-up failed");
                     Result.SetFilteredStackTrace(exp.StackTrace);
                     Result.WriteExceptionToMessage(exp);
                     setupFailed = true;
                 }
             }
             if (!setupFailed)
             {
                 try
                 {
                     TestRunner.RunTest(this);
                 }
                 catch (Exception exp)
                 {
                     Result.Status = TestStatus.Untested;
                     Result.Message.AppendLine("Test runner failed");
                     Result.StackTrace = exp.StackTrace;
                     Result.WriteExceptionToOutput(exp);
                 }
                 if (TearDownMethod != null)
                 {
                     try
                     {
                         TearDownMethod.Invoke(Fixture.Instance, null);
                     }
                     catch (TargetInvocationException tie)
                     {
                         Exception exp = tie.InnerException;
                         Result.Message.AppendLine("Test tear-down failed");
                         Result.WriteExceptionToOutput(exp);
                     }
                 }
             }
         }
         else
         {
             Result.WriteIgnoreToMessage(this, IgnoreReason);
         }
     }
     finally
     {
         End();
     }
 }
Beispiel #2
0
 void Run()
 {
     Begin();
     try
     {
         if (!Ignore)
         {
             if (StartUpMethod != null)
             {
                 try
                 {
                     StartUpMethod.Invoke(Instance, null);
                 }
                 catch (TargetInvocationException tie)
                 {
                     Exception exp = tie.InnerException;
                     foreach (ITest test in Tests)
                     {
                         test.Begin();
                         if (!test.Ignore)
                         {
                             test.Result.Message.AppendLine("Fixture set-up failed");
                             test.Result.SetFilteredStackTrace(exp.StackTrace);
                             test.Result.WriteExceptionToMessage(exp);
                         }
                         else
                         {
                             test.Result.WriteIgnoreToMessage(test, test.IgnoreReason);
                         }
                         test.End();
                     }
                     return;
                 }
             }
             try
             {
                 FixtureRunner.RunTests(this);
             }
             catch (Exception exp)
             {
                 foreach (ITest test in Tests)
                 {
                     if (!test.Ignore)
                     {
                         test.Result.Message.AppendLine("Fixture runner failed");
                         test.Result.WriteExceptionToOutput(exp);
                         if (test.Result.Status == TestStatus.Untested)
                         {
                             test.Begin();
                             test.Result.StackTrace = exp.StackTrace;
                             test.End();
                         }
                     }
                     else if (test.Result.Status == TestStatus.Untested)
                     {
                         test.Begin();
                         test.Result.WriteIgnoreToMessage(test, test.IgnoreReason);
                         test.End();
                     }
                 }
             }
             if (TearDownMethod != null)
             {
                 try
                 {
                     TearDownMethod.Invoke(Instance, null);
                 }
                 catch (TargetInvocationException tie)
                 {
                     Exception exp = tie.InnerException;
                     foreach (ITest test in Tests)
                     {
                         if (!test.Ignore)
                         {
                             test.Result.Message.AppendLine("Fixture tear-down failed");
                             test.Result.WriteExceptionToOutput(exp);
                         }
                     }
                 }
             }
         }
         else
         {
             foreach (ITest test in Tests)
             {
                 test.Begin();
                 test.Result.WriteIgnoreToMessage(test, IgnoreReason);
                 test.End();
             }
         }
     }
     finally
     {
         End();
     }
 }