Beispiel #1
0
 public void SetUp()
 {
     mockTestFixture = new MockTestFixture();
     testSuite       = new TestSuite("Mock Test Suite");
     testSuite.Add(mockTestFixture);
     mock3 = (NUnit.Core.TestCase)findTest("MockTest3", testSuite);
 }
Beispiel #2
0
        public void CountTestCasesFilteredByName()
        {
            TestSuite testSuite = new TestSuite("Mock Test Suite");

            testSuite.Add(mockTestFixture);
            Assert.AreEqual(MockTestFixture.Tests, testSuite.CountTestCases(EmptyFilter.Empty));

            NUnit.Core.TestCase mock3  = (NUnit.Core.TestCase)findTest("MockTest3", testSuite);
            NUnit.Core.TestCase mock1  = (NUnit.Core.TestCase)findTest("MockTest1", testSuite);
            NameFilter          filter = new NameFilter(mock3);

            Assert.AreEqual(1, testSuite.CountTestCases(filter));

            ArrayList nodes = new ArrayList();

            nodes.Add(mock3);
            nodes.Add(mock1);
            filter = new NameFilter(nodes);

            Assert.AreEqual(2, testSuite.CountTestCases(filter));

            filter = new NameFilter(testSuite);

            Assert.AreEqual(MockTestFixture.Tests, testSuite.CountTestCases(filter));
        }
 public AbstractTestCaseDecoration( TestCase testCase )
     : base(testCase.TestName.FullName, testCase.TestName.Name)
 {
     this.testCase = testCase;
     this.RunState = testCase.RunState;
     this.IgnoreReason = testCase.IgnoreReason;
 }
Beispiel #4
0
        public void TestDoesNotMatch()
        {
            NUnit.Core.TestCase mock1  = (NUnit.Core.TestCase)findTest("MockTest1", testSuite);
            NameFilter          filter = new NameFilter(mock1);

            Assert.IsFalse(filter.Pass(mock3), "Name Filter did pass test case");
            Assert.IsTrue(filter.Pass(testSuite), "Name Filter did not pass test suite");
        }
Beispiel #5
0
        public void GoodSignature()
        {
            string    methodName = "TestVoid";
            TestSuite fixture    = LoadFixture("NUnit.Tests.TestClasses.SignatureTestFixture");

            NUnit.Core.TestCase foundTest = FindTestByName(fixture, methodName);
            Assert.IsNotNull(foundTest);
            Assert.IsTrue(foundTest.ShouldRun);
        }
Beispiel #6
0
        public void LoadMethodCategories()
        {
            HasCategories fixture = new HasCategories();

            NUnit.Core.TestCase testCase = TestCaseBuilder.Make(fixture, "ATest");
            Assert.IsNotNull(testCase);
            Assert.IsNotNull(testCase.Categories);
            Assert.AreEqual(2, testCase.Categories.Count);
        }
Beispiel #7
0
        public void CreateIgnoredTestCase()
        {
            MockTestFixture mockTestFixture = new MockTestFixture();

            NUnit.Core.TestCase testCase = TestCaseBuilder.Make(mockTestFixture, "MockTest4");
            Assert.AreEqual(1, testCase.CountTestCases());
            Assert.AreEqual(false, testCase.ShouldRun);
            Assert.AreEqual("ignoring this test method for now", testCase.IgnoreReason);
        }
Beispiel #8
0
		public override bool Pass(TestCase test)
		{
			if ( categories.Count == 0 )
				return true;
			return CheckCategories( test ) ? !Exclude : Exclude ;

//			if (CheckCategories(test.Parent))
//				return true;
//
//			return CheckCategories(test);
		}
Beispiel #9
0
        public void SetUp()
        {
            MockTestFixture mock = new MockTestFixture();

            testSuite = new TestSuite("MyTestSuite");
            testSuite.Add(mock);

            testFixture = (TestSuite)testSuite.Tests[0];

            testCase1 = (NUnit.Core.TestCase)testFixture.Tests[0];
        }
Beispiel #10
0
        private void InvalidSignatureTest(string methodName, string reason)
        {
            TestSuite fixture = LoadFixture("NUnit.Tests.TestClasses.SignatureTestFixture");

            NUnit.Core.TestCase foundTest = FindTestByName(fixture, methodName);
            Assert.IsNotNull(foundTest);
            Assert.IsFalse(foundTest.ShouldRun);
            string expected = String.Format("Method {0}'s signature is not correct: {1}.", methodName, reason);

            Assert.AreEqual(expected, foundTest.IgnoreReason);
        }
        public void SetUp()
        {
            testSuite   = new TestSuite("MyTestSuite");
            testFixture = TestFixtureBuilder.BuildFrom(typeof(MockTestFixture));
            testSuite.Add(testFixture);

            suiteInfo   = new TestInfo(testSuite);
            fixtureInfo = new TestInfo(testFixture);

            testCase     = (NUnit.Core.TestCase)testFixture.Tests[0];
            testCaseInfo = new TestInfo(testCase);
        }
Beispiel #12
0
        public void TestExpectedException()
        {
            TestSuite suite = new TestSuite("mock suite");

            suite.Add(new ExpectExceptionTest());

            IList     tests     = suite.Tests;
            TestSuite rootSuite = (TestSuite)tests[0];

            NUnit.Core.TestCase testCase = (NUnit.Core.TestCase)rootSuite.Tests[0];
            Assert.AreEqual("NUnit.Tests.Core.ExpectExceptionTest.TestSingle", testCase.FullName);
        }
Beispiel #13
0
        public void RunIgnoredTestCase()
        {
            MockTestFixture mockTestFixture = new MockTestFixture();

            NUnit.Core.TestCase testCase = TestCaseBuilder.Make(mockTestFixture, "MockTest4");
            Assert.AreEqual(1, testCase.CountTestCases());

            TestResult       result     = testCase.Run(NullListener.NULL);
            ResultSummarizer summarizer = new ResultSummarizer(result);

            Assert.AreEqual(0, summarizer.ResultCount);
            Assert.AreEqual(1, summarizer.TestsNotRun);
        }
Beispiel #14
0
        public void MultipleNameMatch()
        {
            NUnit.Core.TestCase mock1    = (NUnit.Core.TestCase)findTest("MockTest1", testSuite);
            ArrayList           testList = new ArrayList();

            testList.Add(mock3);
            testList.Add(mock1);
            NameFilter filter = new NameFilter(testList);

            Assert.IsTrue(filter.Pass(mock3), "Name Filter did not pass test case");
            Assert.IsTrue(filter.Pass(mock1), "Name Filter did not pass test case");
            Assert.IsTrue(filter.Pass((TestSuite)testSuite.Tests[0]), "Name Filter did not pass test suite");
        }
Beispiel #15
0
        public void TestName()
        {
            TestSuite   suite       = new TestSuite("mock suite");
            OneTestCase oneTestCase = new OneTestCase();

            suite.Add(oneTestCase);

            IList     tests     = suite.Tests;
            TestSuite rootSuite = (TestSuite)tests[0];

            NUnit.Core.TestCase testCase = (NUnit.Core.TestCase)rootSuite.Tests[0];
            Assert.AreEqual("NUnit.Tests.Core.OneTestCase.TestCase", testCase.FullName);
            Assert.AreEqual("TestCase", testCase.Name);
        }
        public void SetUp()
        {
            MockTestFixture mock = new MockTestFixture();

            testSuite = new TestSuite("MyTestSuite");
            testSuite.Add(mock);
            suiteInfo = new UITestNode(testSuite);

            testFixture = (TestSuite)testSuite.Tests[0];
            fixtureInfo = new UITestNode(testFixture);

            testCase     = (NUnit.Core.TestCase)testFixture.Tests[0];
            testCaseInfo = new UITestNode(testCase);
        }
Beispiel #17
0
		public override bool Pass(TestCase test) 
		{
			bool passed = Exclude;

			foreach(Test node in testNodes) 
			{
				if (test.IsDescendant(node) || test == node) 
				{
					passed = !Exclude;
					break;
				}
			}

			return passed;
		}
		public AbstractTestCaseDecoration( TestCase testCase )
			: base( (TestName)testCase.TestName.Clone() )
		{
			this.testCase = testCase;
			this.RunState = testCase.RunState;
			this.IgnoreReason = testCase.IgnoreReason;
            this.Description = testCase.Description;
            this.Categories = new System.Collections.ArrayList(testCase.Categories);
            if (testCase.Properties != null)
            {
                this.Properties = new ListDictionary();
                foreach (DictionaryEntry entry in testCase.Properties)
                    this.Properties.Add(entry.Key, entry.Value);
            }
        }
Beispiel #19
0
        public void RunningSingleMethodCallsSetUpAndTearDown()
        {
            SetUpAndTearDownFixture testFixture = new SetUpAndTearDownFixture();
            TestSuite suite = new TestSuite("SetUpAndTearDownSuite");

            suite.Add(testFixture);
            TestSuite fixtureSuite = (TestSuite)suite.Tests[0];

            NUnit.Core.TestCase testCase = (NUnit.Core.TestCase)fixtureSuite.Tests[0];

            suite.Run(NullListener.NULL);

            Assert.AreEqual(1, testFixture.setUpCount);
            Assert.AreEqual(1, testFixture.tearDownCount);
        }
        public void RepeatTestFiveTimes()
        {
            NUnit.Core.TestCase baseCase = TestCaseBuilder.Make(new SuccessTest(), "Success");
            Test repeatTest = new RepeatedTest(baseCase, 5);

            int expectedCount = 5 * SuccessTest.Tests;

            Assert.AreEqual(expectedCount, repeatTest.CountTestCases());
            Assert.AreEqual(expectedCount, repeatTest.CountTestCases(EmptyFilter.Empty));

            TestResult result = repeatTest.Run(NullListener.NULL);

            Assert.IsTrue(result.IsSuccess);

            Assert.IsTrue(result is TestSuiteResult);
            TestSuiteResult suiteResult = (TestSuiteResult)result;

            Assert.AreEqual(expectedCount, suiteResult.Results.Count);
        }
Beispiel #21
0
        public void IgnoredFixtureShouldNotCallFixtureSetUpOrTearDown()
        {
            IgnoredFixture testFixture = new IgnoredFixture();
            TestSuite      suite       = new TestSuite("IgnoredFixtureSuite");

            suite.Add(testFixture);
            TestSuite fixtureSuite = (TestSuite)suite.Tests[0];

            NUnit.Core.TestCase testCase = (NUnit.Core.TestCase)fixtureSuite.Tests[0];

            fixtureSuite.Run(NullListener.NULL);
            Assert.IsFalse(testFixture.setupCalled, "TestFixtureSetUp called running fixture");
            Assert.IsFalse(testFixture.teardownCalled, "TestFixtureTearDown called running fixture");

            suite.Run(NullListener.NULL);
            Assert.IsFalse(testFixture.setupCalled, "TestFixtureSetUp called running enclosing suite");
            Assert.IsFalse(testFixture.teardownCalled, "TestFixtureTearDown called running enclosing suite");

            testCase.Run(NullListener.NULL);
            Assert.IsFalse(testFixture.setupCalled, "TestFixtureSetUp called running a test case");
            Assert.IsFalse(testFixture.teardownCalled, "TestFixtureTearDown called running a test case");
        }
Beispiel #22
0
        private NUnit.Core.TestCase FindTestByName(TestSuite fixture, string methodName)
        {
            NUnit.Core.TestCase foundTest = null;
            foreach (Test test in fixture.Tests)
            {
                NUnit.Core.TestCase testCase = test as NUnit.Core.TestCase;
                if (testCase != null)
                {
                    if (testCase.Name.Equals(methodName))
                    {
                        foundTest = testCase;
                    }
                }

                if (foundTest != null)
                {
                    break;
                }
            }

            return(foundTest);
        }
Beispiel #23
0
 public void TestStarted(TestCase testCase)
 {
     currentTestName = testCase.FullName;
 }
Beispiel #24
0
 public void TestStarted(NUnit.Core.TestCase testCase)
 {
     testCaseStart++;
 }
 void EventListener.TestStarted(TestCase testCase)
 {
     UnitTest t = GetLocalTest (testCase);
     runningTest = t;
     context.Monitor.BeginTest (t);
     t.Status = TestStatus.Running;
 }
Beispiel #26
0
		public override bool Pass(TestCase test)
		{
			return true;
		}
Beispiel #27
0
 /// <summary>
 /// Trigger event when each test starts
 /// </summary>
 /// <param name="testCase">TestCase that is starting</param>
 void EventListener.TestStarted(NUnit.Core.TestCase testCase)
 {
     events.FireTestStarting(testCase);
 }
Beispiel #28
0
			public void TestStarted(TestCase testCase)
			{
				currentTestName = testCase.FullName;

				if ( options.labels )
					writer.WriteLine("***** {0}", testCase.FullName );
				else if ( !options.xmlConsole )
					Console.Write(".");
}
Beispiel #29
0
 public void TestStarted(NUnit.Core.TestCase testCase)
 {
     testStarted.Add(testCase.Name);
 }
        /// <summary>
        /// Makes a TestCase from an NUnit test, adding
        /// navigation data if it can be found.
        /// </summary>
        private TestCase MakeTestCaseFromNUnitTest(ITest nunitTest)
        {
            //var testCase = MakeTestCaseFromTestName(nunitTest.TestName);
            var testCase = new TestCase(
                                     nunitTest.TestName.FullName,
                                     new Uri(NUnitTestExecutor.ExecutorUri),
                                     this.sourceAssembly)
            {
                DisplayName = nunitTest.TestName.Name,
                CodeFilePath = null,
                LineNumber = 0
            };

            var navData = GetNavigationData(nunitTest.ClassName, nunitTest.MethodName);
            if (navData != null)
            {
                testCase.CodeFilePath = navData.FileName;
                testCase.LineNumber = navData.MinLineNumber;
            }

            testCase.AddTraitsFromNUnitTest(nunitTest);

            return testCase;
        }
Beispiel #31
0
		public void TestStarted(TestCase testCase)
		{
			if ( displayTestLabels )
				outText.WriteLine("***** {0}", testCase.FullName );
			
			this.listener.TestStarted( testCase );
			events.FireTestStarting( testCase );
		}
Beispiel #32
0
		public void TestStarted(TestCase testCase){}
Beispiel #33
0
		public abstract bool Pass(TestCase test);
Beispiel #34
0
 public void NoDescription()
 {
     NUnit.Core.TestCase testCase = TestCaseBuilder.Make(fixture, "NoDescriptionMethod");
     Assert.IsNull(testCase.Description);
 }
Beispiel #35
0
 public void Init()
 {
     testCase = TestCaseBuilder.Make(fixture, "Method");
 }
        public void SetUp()
        {
            testSuite = new TestSuite("MyTestSuite");
            testFixture = TestFixtureBuilder.BuildFrom( typeof( MockTestFixture ) );
            testSuite.Add( testFixture );

            suiteInfo = new TestInfo( testSuite );
            fixtureInfo = new TestInfo( testFixture );

            testCase = (NUnit.Core.TestCase)testFixture.Tests[0];
            testCaseInfo = new TestInfo( testCase );
        }
 public void TestStarted(TestCase testCase)
 {
     currentTestName = testCase.FullName;
 }
Beispiel #38
0
 public abstract bool Pass(TestCase test);