public override void DoFixtureSetUp(TestResult suiteResult)
        {
            try
            {
                _fixture.FixtureSetup();

                Status = SetUpState.SetUpComplete;
            }
            catch (Exception ex)
            {
                if (ex is NunitException || ex is TargetInvocationException)
                    ex = ex.InnerException;

                if (testFramework.IsIgnoreException(ex))
                {
                    ShouldRun = false;
                    suiteResult.NotRun(ex.Message);
                    suiteResult.StackTrace = ex.StackTrace;
                    IgnoreReason = ex.Message;
                }
                else
                {
                    suiteResult.Failure(ex.Message, ex.StackTrace);
                    Status = SetUpState.SetUpFailed;
                }
            }
            finally
            {
                if (testFramework != null)
                    suiteResult.AssertCount = testFramework.GetAssertCount();
            }
        }
Example #2
0
        public override void DoSetUp(TestResult suiteResult)
        {
            try
            {
                if (Fixture == null)
                {
                    Fixture = Reflect.Construct(fixtureType);
                }

                if (this.fixtureSetUp != null)
                {
                    Reflect.InvokeMethod(fixtureSetUp, Fixture);
                }
                IsSetUp = true;
            }
            catch (Exception ex)
            {
                // Error in TestFixtureSetUp causes the suite and
                // all contained suites to be ignored.
                // TODO: Change this to be a failure?
                NunitException nex = ex as NunitException;
                if (nex != null)
                {
                    ex = nex.InnerException;
                }

                if (ex is NUnit.Framework.IgnoreException)
                {
                    this.ShouldRun = false;
                    suiteResult.NotRun(ex.Message);
                    suiteResult.StackTrace = ex.StackTrace;
                    this.IgnoreReason      = ex.Message;
                }
                else
                {
                    suiteResult.Failure(ex.Message, ex.StackTrace, true);
                }
            }
            finally
            {
                suiteResult.AssertCount = NUnit.Framework.Assert.Counter;
            }
        }
Example #3
0
		public override void DoSetUp( TestResult suiteResult )
		{
			try 
			{
				if ( Fixture == null )
					Fixture = Reflect.Construct( fixtureType );

				if (this.fixtureSetUp != null)
					Reflect.InvokeMethod(fixtureSetUp, Fixture);
				IsSetUp = true;
			} 
			catch (Exception ex) 
			{
				// Error in TestFixtureSetUp causes the suite and
				// all contained suites to be ignored.
				// TODO: Change this to be a failure?
				NunitException nex = ex as NunitException;
				if (nex != null)
					ex = nex.InnerException;

				if ( ex is NUnit.Framework.IgnoreException )
				{
					this.ShouldRun = false;
					suiteResult.NotRun(ex.Message);
					suiteResult.StackTrace = ex.StackTrace;
					this.IgnoreReason = ex.Message;
				}
				else
				{
					suiteResult.Failure( ex.Message, ex.StackTrace, true );
				}
			}
			finally
			{
				suiteResult.AssertCount = NUnit.Framework.Assert.Counter;
			}
		}
 protected void RecordException(Exception ex, TestResult testResult)
 {
     if (testFramework.IsIgnoreException(ex))
         testResult.NotRun(ex.Message);
     else if (testFramework.IsAssertException(ex))
         testResult.Failure(ex.Message, ex.StackTrace);
     else
         testResult.Failure(BuildMessage(ex), BuildStackTrace(ex));
 }