Esempio n. 1
0
        private TestSuiteResult MockSuiteResult(string suiteName, bool failure)
        {
            TestSuiteResult result = new TestSuiteResult(suiteName);
            result.Time = time;
            result.RunState = RunState.Executed;

            TestSuiteResult level1SuiteA = new TestSuiteResult("level 1 A");
            result.AddResult(level1SuiteA);
            level1SuiteA.RunState = RunState.Executed;

            TestSuiteResult level1SuiteB = new TestSuiteResult("level 1 B");
            result.AddResult(level1SuiteB);
            level1SuiteB.RunState = RunState.Executed;

            testCase = new TestCaseResult("a test case");
            if(failure) testCase.Failure("argument exception",null);
            else testCase.Success();

            level1SuiteA.AddResult(testCase);

            testCase = new TestCaseResult("a successful test");
            testCase.Success();
            level1SuiteB.AddResult(testCase);

            testCase = new TestCaseResult("a not run test");
            testCase.Ignore("test not run");
            level1SuiteB.AddResult(testCase);

            return result;
        }
Esempio n. 2
0
        private void RunAllTests(
            TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
        {
            foreach (Test test in ArrayList.Synchronized(Tests))
            {
                if (filter.Pass(test))
                {
                    RunState saveRunState = test.RunState;

                    if (test.RunState == RunState.Runnable && this.RunState != RunState.Runnable && this.RunState != RunState.Explicit)
                    {
                        test.RunState     = this.RunState;
                        test.IgnoreReason = this.IgnoreReason;
                    }

                    TestResult result = test.Run(listener, filter);

                    suiteResult.AddResult(result);

                    if (saveRunState != test.RunState)
                    {
                        test.RunState     = saveRunState;
                        test.IgnoreReason = null;
                    }
                }
            }
        }
Esempio n. 3
0
        private TestResult SimulateTest( TestNode test, bool ignore )
        {
            if ( test.RunState != RunState.Runnable )
                ignore = true;

            if ( test.IsSuite )
            {
                FireSuiteStarting( test.TestName );

                TestSuiteResult result = new TestSuiteResult( test, test.TestName.Name );

                foreach( TestNode childTest in test.Tests )
                    result.AddResult( SimulateTest( childTest, ignore ) );

                FireSuiteFinished( result );

                return result;
            }
            else
            {
                FireTestStarting( test.TestName );

                TestCaseResult result = new TestCaseResult( test );

                result.RunState = ignore ? RunState.Ignored : RunState.Executed;

                FireTestFinished( result );

                return result;
            }
        }
Esempio n. 4
0
        protected virtual void RunAllTests(
            TestSuiteResult suiteResult, EventListener listener, IFilter filter)
        {
            foreach (Test test in ArrayList.Synchronized(Tests))
            {
                bool saveShouldRun = test.ShouldRun;

                if (test.ShouldRun)
                {
                    if (this.ShouldRun == false)
                    {
                        test.ShouldRun    = false;
                        test.IgnoreReason = this.IgnoreReason;
                    }
                    else if (test.IsExplicit && filter == null)
                    {
                        test.ShouldRun    = false;
                        test.IgnoreReason = EXPLICIT_SELECTION_REQUIRED;
                    }
                }

                if (filter == null || test.Filter(filter))
                {
                    suiteResult.AddResult(test.Run(listener, filter));
                }

                if (saveShouldRun && !test.ShouldRun)
                {
                    test.ShouldRun    = true;
                    test.IgnoreReason = null;
                }
            }
        }
Esempio n. 5
0
        //private TestCaseResult testCase;
        private TestSuiteResult MockSuiteResult( bool failure )
        {
            TestCaseResult testCaseResult = new TestCaseResult("a test case");
            if ( failure ) testCaseResult.Failure( "case failed", null );

            TestSuiteResult level1SuiteA = new TestSuiteResult("level 1 A");
            level1SuiteA.AddResult(testCaseResult);

            TestSuiteResult level1SuiteB = new TestSuiteResult("level 1 B");
            level1SuiteB.AddResult(new TestCaseResult("a successful test"));

            TestSuiteResult result = new TestSuiteResult("base");
            result.AddResult(level1SuiteA);
            result.AddResult(level1SuiteB);

            return result;
        }
Esempio n. 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);
     }
 }
Esempio n. 7
0
 private void MarkTestFailed(
     Test test, TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
 {
     if (test is TestSuite)
     {
         listener.SuiteStarted(test.TestName);
         TestSuiteResult result = new TestSuiteResult(new TestInfo(test), test.TestName.FullName);
         string          msg    = string.Format("Parent SetUp failed in {0}", this.FixtureType.Name);
         result.Failure(msg, null, FailureSite.Parent);
         MarkTestsFailed(test.Tests, suiteResult, listener, filter);
         suiteResult.AddResult(result);
         listener.SuiteFinished(result);
     }
     else
     {
         listener.TestStarted(test.TestName);
         TestCaseResult result = new TestCaseResult(new TestInfo(test));
         string         msg    = string.Format("TestFixtureSetUp failed in {0}", this.FixtureType.Name);
         result.Failure(msg, null, FailureSite.Parent);
         suiteResult.AddResult(result);
         listener.TestFinished(result);
     }
 }
Esempio n. 8
0
        public void ClearResults()
        {
            TestCaseResult testCaseResult = new TestCaseResult( testCaseInfo );
            testCaseResult.Success();
            TestSuiteResult testSuiteResult = new TestSuiteResult( fixtureInfo, "MockTestFixture" );
            testSuiteResult.AddResult( testCaseResult );
            testSuiteResult.RunState = RunState.Executed;

            TestSuiteTreeNode node1 = new TestSuiteTreeNode( testSuiteResult );
            TestSuiteTreeNode node2 = new TestSuiteTreeNode( testCaseResult );
            node1.Nodes.Add( node2 );

            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.SelectedImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.SelectedImageIndex );

            node1.ClearResults();

            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.SelectedImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.ImageIndex );
            Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.SelectedImageIndex );
        }
Esempio n. 9
0
        private void RunAllTests(
            TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
        {
            foreach (Test test in ArrayList.Synchronized(Tests))
            {
                if (filter.Pass(test))
                {
                    RunState saveRunState = test.RunState;

                    if (test.RunState == RunState.Runnable && this.RunState != RunState.Runnable && this.RunState != RunState.Explicit )
                    {
                        test.RunState = this.RunState;
                        test.IgnoreReason = this.IgnoreReason;
                    }

                    TestResult result = test.Run(listener, filter);

                    suiteResult.AddResult(result);

                    if (saveRunState != test.RunState)
                    {
                        test.RunState = saveRunState;
                        test.IgnoreReason = null;
                    }
                }
            }
        }
Esempio n. 10
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);
     }
 }
Esempio n. 11
0
 private void MarkTestFailed(
     Test test, TestSuiteResult suiteResult, EventListener listener, ITestFilter filter)
 {
     if (test is TestSuite)
     {
         listener.SuiteStarted(test.TestName);
         TestSuiteResult result = new TestSuiteResult( new TestInfo(test), test.TestName.FullName);
         string msg = string.Format( "Parent SetUp failed in {0}", this.FixtureType.Name );
         result.Failure(msg, null, FailureSite.Parent);
         MarkTestsFailed(test.Tests, suiteResult, listener, filter);
         suiteResult.AddResult(result);
         listener.SuiteFinished(result);
     }
     else
     {
         listener.TestStarted(test.TestName);
         TestCaseResult result = new TestCaseResult( new TestInfo(test) );
         string msg = string.Format( "TestFixtureSetUp failed in {0}", this.FixtureType.Name );
         result.Failure(msg, null, FailureSite.Parent);
         suiteResult.AddResult(result);
         listener.TestFinished(result);
     }
 }
Esempio n. 12
0
        public override TestResult Run(EventListener listener, ITestFilter filter)
        {
            TestSuiteResult suite_result = new TestSuiteResult (new TestInfo (this), TestName.FullName);

            DebuggerTestHost host = DebuggerTestHost.Create ();
            if (host == null) {
                TestCaseResult error = new TestCaseResult (new TestInfo (this));
                string msg = String.Format ("Failed to create DebuggerTestHost in {0}", FixtureType.Name);
                error.Failure (msg, null, FailureSite.Parent);
                suite_result.AddResult (error);
                return suite_result;
            }

            int timeout;
            if (Attribute.Timeout != 0)
                timeout = Attribute.Timeout;
            else
                timeout = DebuggerTestAddIn.DefaultTimeout;

            int repeat = 1;
            if (Attribute.Repeat != 0)
                repeat = Attribute.Repeat;

            try {
                for (int i = 0; i < repeat; i++) {
                    if (!host.Run (new TestInfo (this), suite_result, Type.AssemblyQualifiedName, listener, filter, timeout))
                        break;
                }

                return suite_result;
            } finally {
                host.Dispose ();
            }
        }
Esempio n. 13
0
        public bool Run(TestInfo test, TestSuiteResult suite_result, string test_name, EventListener listener, ITestFilter filter, int timeout)
        {
            listener = new ProxyListener (listener);

            TestRunnerDelegate runner = new TestRunnerDelegate (delegate {
                return server.Run (test_name, listener, filter);
            });

            IAsyncResult ar = runner.BeginInvoke (test_name, null, filter, null, null);

            if (!ar.AsyncWaitHandle.WaitOne (timeout) || !ar.IsCompleted) {
                TestCaseResult error = new TestCaseResult (test);
                string msg = String.Format ("Timeout after {0} ms", timeout);
                error.Failure (msg, null, FailureSite.Parent);
                suite_result.AddResult (error);
                return false;
            }

            try {
                TestResult result = runner.EndInvoke (ar);
                if (result != null) {
                    suite_result.AddResult (result);
                    return true;
                }

                TestCaseResult error = new TestCaseResult (test);
                error.Failure ("Unknown error", null, FailureSite.Parent);
                suite_result.AddResult (error);
                return false;
            } catch (Exception ex) {
                TestCaseResult error = new TestCaseResult (test);
                string msg = String.Format ("Unknown exception: {0}", ex);
                error.Failure (msg, null, FailureSite.Parent);
                suite_result.AddResult (error);
                return false;
            }
        }
Esempio n. 14
0
		public virtual TestResult Run(EventListener listener, ITestFilter filter )
		{
			// Save active listener for derived classes
			this.listener = listener;

			ITest[] tests = new ITest[runners.Count];
			for( int index = 0; index < runners.Count; index++ )
				tests[index] = ((TestRunner)runners[index]).Test;

			this.listener.RunStarted( this.Test.TestName.Name, this.CountTestCases( filter ) );

			this.listener.SuiteStarted( this.Test.TestName );
			long startTime = DateTime.Now.Ticks;

			TestSuiteResult result = new TestSuiteResult( new TestInfo( testName, tests ), projectName );
			result.RunState = RunState.Executed;
			foreach( TestRunner runner in runners )
				if ( filter.Pass( runner.Test ) )
					result.AddResult( runner.Run( this, filter ) );
			
			long stopTime = DateTime.Now.Ticks;
			double time = ((double)(stopTime - startTime)) / (double)TimeSpan.TicksPerSecond;
			result.Time = time;

			this.listener.SuiteFinished( result );

			this.listener.RunFinished( result );

			this.testResult = result;

			return result;
		}
Esempio n. 15
0
        private TestSuiteResult NotRunTestSuite()
        {
            TestSuiteResult result = new TestSuiteResult("RootSuite");
            result.RunState = RunState.Executed;

            TestCaseResult testCaseResult = new TestCaseResult("NonRunTestCase");
            testCaseResult.Ignore("No Reason");
            result.AddResult(testCaseResult);

            return result;
        }
Esempio n. 16
0
		protected virtual void RunAllTests(
			TestSuiteResult suiteResult, EventListener listener, IFilter filter )
		{
			foreach(Test test in ArrayList.Synchronized(Tests))
			{
				bool saveShouldRun = test.ShouldRun;

				if (test.ShouldRun)
				{
					if (this.ShouldRun == false)
					{
						test.ShouldRun = false;
						test.IgnoreReason = this.IgnoreReason;
					}
					else if ( test.IsExplicit && filter == null )
					{
						test.ShouldRun = false;
						test.IgnoreReason = EXPLICIT_SELECTION_REQUIRED;
					}
				}
					
				if ( filter == null || test.Filter( filter ) )
				{
					suiteResult.AddResult( test.Run( listener, filter ) );
				}
				
				if ( saveShouldRun && !test.ShouldRun ) 
				{
					test.ShouldRun = true;
					test.IgnoreReason = null;
				}
			}
		}