Example #1
0
        public override void Run(TestCaseResult testResult)
        {
            if (ShouldRun)
            {
                bool doParentSetUp = false;
                if (Parent != null)
                {
                    doParentSetUp = !Parent.IsSetUp;
                }

                try
                {
                    if (doParentSetUp)
                    {
                        Parent.DoSetUp(testResult);
                    }

                    if (Fixture == null && Parent != null)
                    {
                        Fixture = Parent.Fixture;
                    }

                    if (!testResult.IsFailure)
                    {
                        doRun(testResult);
                    }
                }
                catch (Exception ex)
                {
                    if (ex is NunitException)
                    {
                        ex = ex.InnerException;
                    }

                    if (ex is NUnit.Framework.IgnoreException)
                    {
                        testResult.NotRun(ex.Message);
                    }
                    else
                    {
                        RecordException(ex, testResult);
                    }
                }
                finally
                {
                    if (doParentSetUp)
                    {
                        Parent.DoTearDown(testResult);
                    }
                }
            }
            else
            {
                testResult.NotRun(this.IgnoreReason);
            }
        }
Example #2
0
        /// <summary>
        /// The doRun method is used to run a test internally.
        /// It assumes that the caller is taking care of any
        /// TestFixtureSetUp and TestFixtureTearDown needed.
        /// </summary>
        /// <param name="testResult">The result in which to record success or failure</param>
        public void doRun(TestCaseResult testResult)
        {
            DateTime start = DateTime.Now;

            try
            {
                Reflect.InvokeSetUp(this.Fixture);
                doTestCase(testResult);
            }
            catch (Exception ex)
            {
                if (ex is NunitException)
                {
                    ex = ex.InnerException;
                }

                if (ex is NUnit.Framework.IgnoreException)
                {
                    testResult.NotRun(ex.Message);
                }
                else
                {
                    RecordException(ex, testResult);
                }
            }
            finally
            {
                doTearDown(testResult);

                DateTime stop = DateTime.Now;
                TimeSpan span = stop.Subtract(start);
                testResult.Time = (double)span.Ticks / (double)TimeSpan.TicksPerSecond;
            }
        }
Example #3
0
		public override void Run(TestCaseResult testResult)
		{ 
			if ( ShouldRun )
			{
				bool doParentSetUp = false;
				if ( Parent != null )
				{
					doParentSetUp = !Parent.IsSetUp;
					
				}

				try
				{
					if ( doParentSetUp )
						Parent.DoSetUp( testResult );

					if ( Fixture == null && Parent != null)
						Fixture = Parent.Fixture;

					if ( !testResult.IsFailure )
						doRun( testResult );
				}
				catch(Exception ex)
				{
					if ( ex is NunitException )
						ex = ex.InnerException;

					if ( ex is NUnit.Framework.IgnoreException )
						testResult.NotRun( ex.Message );
					else
						RecordException( ex, testResult );
				}
				finally
				{
					if ( doParentSetUp )
						Parent.DoTearDown( testResult );
				}
			}
			else
			{
				testResult.NotRun(this.IgnoreReason);
			}
		}
Example #4
0
        public override void Run(TestCaseResult result)
        {
            if (ShouldRun)
            {
                DateTime start = DateTime.Now;
                try
                {
                    List<string> expectedLines = CreateStringList(WomDocument.Parse(_expected));

                    WomDocument parseResult = ParseWikiText(_source);
                    List<string> actualLines = CreateStringList(parseResult);

                    CompareStringLists(expectedLines, actualLines);
                    result.Success();
                }
                catch (Exception ex)
                {
                    if (ex is NunitException)
                    {
                        ex = ex.InnerException;
                    }
                    if (testFramework.IsIgnoreException(ex))
                    {
                        result.NotRun(BuildMessage(ex), BuildStackTrace(ex));
                    }
                    else
                    {
                        result.Failure(BuildMessage(ex), BuildStackTrace(ex));
                    }
                }
                finally
                {
                    DateTime stop = DateTime.Now;
                    TimeSpan span = stop.Subtract(start);
                    result.Time = (double)span.Ticks / (double)TimeSpan.TicksPerSecond;
                }
            }
            else
            {
                result.NotRun(this.IgnoreReason);
            }
        }
        public override void Run(TestCaseResult testResult)
        {
            if (ShouldRun)
            {
                bool needParentTearDown = false;

                try
                {
                    if (Parent != null)
                    {
                        if (Parent.SetUpNeeded)
                        {
                            Parent.DoOneTimeSetUp(testResult);
                            needParentTearDown = Parent.SetUpComplete;
                        }

                        if (Parent.SetUpFailed)
                            testResult.Failure("TestFixtureSetUp Failed", testResult.StackTrace);
                    }

                    if (!testResult.IsFailure)
                        doRun(testResult);
                }
                catch (Exception ex)
                {
                    if (ex is NunitException)
                        ex = ex.InnerException;

                    RecordException(ex, testResult);
                }
                finally
                {
                    if (needParentTearDown)
                        Parent.DoOneTimeTearDown(testResult);
                }
            }
            else
            {
                testResult.NotRun(IgnoreReason);
            }
        }
Example #6
0
 private void MarkTestNotRun(
     Test test, RunState runState, string ignoreReason, TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
 {
     if (test is TestSuite)
     {
         listener.SuiteStarted(test.TestName);
         TestSuiteResult result = new TestSuiteResult(new TestInfo(test), test.TestName.FullName);
         result.NotRun(runState, ignoreReason, null);
         MarkTestsNotRun(test.Tests, runState, ignoreReason, suiteResult, listener, filter);
         suiteResult.AddResult(result);
         listener.SuiteFinished(result);
     }
     else
     {
         listener.TestStarted(test.TestName);
         TestCaseResult result = new TestCaseResult(new TestInfo(test));
         result.NotRun(runState, ignoreReason, null);
         suiteResult.AddResult(result);
         listener.TestFinished(result);
     }
 }
Example #7
0
        private void doTestCase(TestCaseResult testResult)
        {
            try
            {
                Reflect.InvokeMethod(this.method, this.Fixture);
                ProcessNoException(testResult);
            }
            catch (Exception ex)
            {
                if (ex is NunitException)
                {
                    ex = ex.InnerException;
                }

                if (ex is NUnit.Framework.IgnoreException)
                {
                    testResult.NotRun(ex.Message);
                }
                else
                {
                    ProcessException(ex, testResult);
                }
            }
        }
Example #8
0
 private void MarkTestNotRun(
     Test test, RunState runState, string ignoreReason, TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
 {
     if (test is TestSuite)
     {
         listener.SuiteStarted(test.TestName);
         TestSuiteResult result = new TestSuiteResult( new TestInfo(test), test.TestName.FullName);
         result.NotRun( runState, ignoreReason, null );
         MarkTestsNotRun(test.Tests, runState, ignoreReason, suiteResult, listener, filter);
         suiteResult.AddResult(result);
         listener.SuiteFinished(result);
     }
     else
     {
         listener.TestStarted(test.TestName);
         TestCaseResult result = new TestCaseResult( new TestInfo(test) );
         result.NotRun( runState, ignoreReason, null );
         suiteResult.AddResult(result);
         listener.TestFinished(result);
     }
 }
Example #9
0
		private void doTestCase( TestCaseResult testResult )
		{
			try
			{
				Reflect.InvokeMethod( this.method, this.Fixture );
				ProcessNoException(testResult);
			}
			catch( Exception ex )
			{
				if ( ex is NunitException )
					ex = ex.InnerException;

				if ( ex is NUnit.Framework.IgnoreException )
					testResult.NotRun( ex.Message );
				else
					ProcessException(ex, testResult);
			}
		}
Example #10
0
		/// <summary>
		/// The doRun method is used to run a test internally.
		/// It assumes that the caller is taking care of any 
		/// TestFixtureSetUp and TestFixtureTearDown needed.
		/// </summary>
		/// <param name="testResult">The result in which to record success or failure</param>
		public void doRun( TestCaseResult testResult )
		{
			DateTime start = DateTime.Now;

			try 
			{
				Reflect.InvokeSetUp( this.Fixture );
				doTestCase( testResult );
			}
			catch(Exception ex)
			{
				if ( ex is NunitException )
					ex = ex.InnerException;

				if ( ex is NUnit.Framework.IgnoreException )
					testResult.NotRun( ex.Message );
				else
					RecordException( ex, testResult );
			}
			finally 
			{
				doTearDown( testResult );

				DateTime stop = DateTime.Now;
				TimeSpan span = stop.Subtract(start);
				testResult.Time = (double)span.Ticks / (double)TimeSpan.TicksPerSecond;
			}
		}
        private void doTestCase(TestCaseResult testResult)
        {
            try
            {
                RunTestMethod(testResult);
                testResult.Success();
            }
            catch (Exception ex)
            {
                if (ex is NunitException)
                    ex = ex.InnerException;

                if (testFramework.IsIgnoreException(ex))
                    testResult.NotRun(ex.Message, BuildStackTrace(ex));
                else
                    RecordException(ex, testResult);
            }
        }
Example #12
0
 public override void Run(TestCaseResult result)
 {
     result.NotRun(base.IgnoreReason);
 }
		public override void Run(TestCaseResult result)
		{
			result.NotRun(base.IgnoreReason);
		}