Example #1
0
        protected virtual void Run(TestResult result, TestListener listener)
        {
            IgnoreAttribute ignore = (IgnoreAttribute)Reflect.GetAttribute(method, typeof(IgnoreAttribute));

            if (this.RunState == RunState.NotRunnable)
            {
                result.Failure(this.ignoreReason);
            }
            else if (ignore != null)
            {
                result.NotRun(ignore.Reason);
            }
            else
            {
                try
                {
                    RunBare();
                    result.Success();
                }
                catch (NUnitLiteException nex)
                {
                    result.RecordException(nex.InnerException);
                }
#if !NETCF_1_0
                catch (System.Threading.ThreadAbortException)
                {
                    throw;
                }
#endif
                catch (Exception ex)
                {
                    result.RecordException(ex);
                }
            }
        }
Example #2
0
        public TestResult Run(TestListener listener)
        {
            int count = 0, failures = 0, errors = 0;

            listener.TestStarted(this);
            TestResult result = new TestResult(this);

            switch (this.RunState)
            {
            case RunState.NotRunnable:
                result.Error(this.IgnoreReason);
                break;

            case RunState.Ignored:
                result.NotRun(this.IgnoreReason);
                break;

            case RunState.Runnable:
                foreach (ITest test in tests)
                {
                    ++count;
                    TestResult r = test.Run(listener);
                    result.AddResult(r);
                    switch (r.ResultState)
                    {
                    case ResultState.Error:
                        ++errors;
                        break;

                    case ResultState.Failure:
                        ++failures;
                        break;

                    default:
                        break;
                    }
                }

                if (count == 0)
                {
                    result.NotRun("Class has no tests");
                }
                else if (errors > 0 || failures > 0)
                {
                    result.Failure("One or more component tests failed");
                }
                else
                {
                    result.Success();
                }
                break;
            }

            listener.TestFinished(result);
            return(result);
        }
Example #3
0
		public override void RunAsync (TestListener listener)
		{
			IgnoreAttribute ignore = (IgnoreAttribute) Reflect.GetAttribute (Method, typeof (IgnoreAttribute));
			
			this.listener = listener;
			tasks = new Queue<ConditionalHandler> ();
			Result = new TestResult (this);
			
			OnStarted (null);
			listener.TestStarted (this);

			is_async = Method.IsDefined (typeof (AsynchronousAttribute), false);
			Current = this;

			if (RunState == RunState.NotRunnable) {
				Result.Failure (IgnoreReason);
			} else if (ignore != null) {
				Result.NotRun (ignore.Reason);
			} else {
				SetUp ();
				try {
					RunTest ();

					if (is_async) {
						Suite.BeginInvoke (ProcessTasks);
					} else {
						Result.Success ();
						RunEnd ();
					}
				} catch (NUnitLiteException nex) {
					Result.RecordException (nex.InnerException);
					RunEnd ();
				} catch (Exception ex) {
					Result.RecordException (ex);
					RunEnd ();
				}
			}
		}
Example #4
0
        protected virtual void Run(TestResult result, ITestListener listener)
        {
            IgnoreAttribute ignore = (IgnoreAttribute)Reflect.GetAttribute(method, typeof(IgnoreAttribute));
            if (this.RunState == RunState.NotRunnable)
                result.Failure(this.ignoreReason);
            else if ( ignore != null )
                result.NotRun(ignore.Reason);
            else
            {
                try
                {
                    RunBare();
                    result.Success();
                }
                catch (NUnitLiteException nex)
                {
                    result.RecordException(nex.InnerException);
                }
#if !NETCF_1_0
                catch (System.Threading.ThreadAbortException)
                {
                    throw;
                }
#endif
                catch (Exception ex)
                {
                    result.RecordException(ex);
                }
            }
        }
Example #5
0
        public TestResult Run(TestListener listener)
        {
            int count = 0, failures = 0, errors = 0;
            listener.TestStarted(this);
            TestResult result = new TestResult(this);

            switch (this.RunState)
            {
                case RunState.NotRunnable:
                    result.Error(this.IgnoreReason);
                    break;

                case RunState.Ignored:
                    result.NotRun(this.IgnoreReason);
                    break;

                case RunState.Runnable:
                    foreach (ITest test in tests)
                    {
                        ++count;
                        TestResult r = test.Run(listener);
                        result.AddResult(r);
                        switch (r.ResultState)
                        {
                            case ResultState.Error:
                                ++errors;
                                break;
                            case ResultState.Failure:
                                ++failures;
                                break;
                            default:
                                break;
                        }
                    }

                    if (count == 0)
                        result.NotRun("Class has no tests");
                    else if (errors > 0 || failures > 0)
                        result.Failure("One or more component tests failed");
                    else
                        result.Success();
                    break;
            }

            listener.TestFinished(result);
            return result;
        }
Example #6
0
        public TestResult Run(TestListener listener)
        {
            int count = 0, failures = 0, errors = 0;
            listener.TestStarted(this);
            TestResult result = new TestResult(this);

            switch (this.RunState)
            {
                case RunState.NotRunnable:
                    result.Error(this.IgnoreReason);
                    break;

                case RunState.Ignored:
                    result.NotRun(this.IgnoreReason);
                    break;

                case RunState.Runnable:
                    if(TestFixtureSetUpMethod != null)
                    {
                        NUnitLite.Reflect.InvokeMethod(TestFixtureSetUpMethod, TestObject);
                    }
                    foreach (ITest test in tests)
                    {
                        ++count;
                        TestResult r = test.Run(listener);
                        result.AddResult(r);
                        switch (r.ResultState)
                        {
                            case ResultState.Error:
                                ++errors;
                                break;
                            case ResultState.Failure:
                                ++failures;
                                break;
                            default:
                                break;
                        }
                    }
                    if (TestFixtureTearDownMethod != null)
                    {
                        NUnitLite.Reflect.InvokeMethod(TestFixtureTearDownMethod, TestObject);
                    }
                    if (count == 0)
                    {
                        result.NotRun("Class has no tests");
                    }
                    else if (errors > 0 || failures > 0)
                    {
                        result.Failure("One or more component tests failed");
                    }
                    else
                    {
                        result.Success();
                    }
                    break;
            }

            listener.TestFinished(result);
            return result;
        }
Example #7
0
 protected override void Run(TestResult result, TestListener listener)
 {
     result.Failure(message);
 }
 protected override void Run(TestResult result, TestListener listener)
 {
     result.Failure(message);
 }