Add() public method

Adds a test to the suite.
public Add ( Test test ) : void
test Test The test.
return void
        public void FixtureDescription()
        {
            TestSuite suite = new TestSuite("suite");
            suite.Add( TestBuilder.MakeFixture( typeof( DescriptionFixture ) ) );

            TestSuite mockFixtureSuite = (TestSuite)suite.Tests[0];

            Assert.AreEqual("Fixture Description", mockFixtureSuite.Properties.Get(PropertyNames.Description));
        }
Example #2
0
        public void FixtureAuthor()
        {
            var suite = new TestSuite("suite");
            suite.Add(TestBuilder.MakeFixture(FixtureType));

            var mockFixtureSuite = (TestSuite)suite.Tests[0];

            Assert.AreEqual("Rob Prouse", mockFixtureSuite.Properties.Get(PropertyNames.Author));
        }
Example #3
0
        public void FixtureTestOf()
        {
            var suite = new TestSuite("suite");
            suite.Add(TestBuilder.MakeFixture(FixtureType));

            var mockFixtureSuite = (TestSuite)suite.Tests[0];

            Assert.AreEqual("NUnit.Framework.TestOfAttribute", mockFixtureSuite.Properties.Get(PropertyNames.TestOf));
        }
        public void IgnoreWorksForTestSuite()
        {
            TestSuite suite = new TestSuite("IgnoredTestFixture");
            suite.Add( TestBuilder.MakeFixture( typeof( IgnoredTestSuiteFixture ) ) );
            ITestResult fixtureResult = TestBuilder.RunTestSuite(suite, null).Children[0];

            Assert.AreEqual(ResultState.Ignored, fixtureResult.ResultState);

            foreach (ITestResult testResult in fixtureResult.Children)
                Assert.AreEqual(ResultState.Ignored, testResult.ResultState);
        }
Example #5
0
        public void IgnoreWorksForTestSuite()
        {
            TestSuite suite = new TestSuite("IgnoredTestFixture");
            suite.Add( TestBuilder.MakeFixture( typeof( IgnoredTestSuiteFixture ) ) );
            ITestResult fixtureResult = TestBuilder.RunTest(suite).Children.ToArray ()[0];

            Assert.AreEqual(ResultState.Ignored.WithSite(FailureSite.SetUp), fixtureResult.ResultState);

            foreach (ITestResult testResult in fixtureResult.Children)
                Assert.AreEqual(ResultState.Ignored.WithSite(FailureSite.Parent), testResult.ResultState);
        }
Example #6
0
        internal static void Run(string title, Stream outputStream)
        {
            var suite = new TestSuite(title);
            var builder = new NUnitLiteTestAssemblyBuilder();
            suite.Add(builder.Build(System.Reflection.Assembly.GetExecutingAssembly(), new Dictionary<string, object>()));

            var testExecutionContext = TestExecutionContext.CurrentContext;
            testExecutionContext.WorkDirectory = Environment.CurrentDirectory;

            #if __IOS__
            var workItem = suite.CreateWorkItem(TestFilter.Empty, new FinallyDelegate());
            #else
            var workItem = suite.CreateWorkItem(TestFilter.Empty);
            #endif
            workItem.Execute(testExecutionContext);

            var testWriter = new NUnitLite.Runner.NUnit2XmlOutputWriter(DateTime.Now);
            using (var writer = new StreamWriter(outputStream))
            {
                testWriter.WriteResultFile(workItem.Result, writer);
            }
        }
 internal static NUnitTest GetSetupTestTarget(Bundle bundle)
 {
     var suiteName = bundle == null ? null : bundle.GetString ("suite");
     TestSuite suite = null;
     if (suiteName != null && !Suites.TryGetValue (suiteName, out suite)) {
         Console.WriteLine ("Invalid suite name: {0}", suiteName);
         Console.WriteLine ("Supported suite names:");
         foreach (KeyValuePair<string, TestSuite> e in Suites)
             Console.WriteLine ("\t{0}", e.Key);
         return new TestSuite ("__error__");
     }
     if (suite != null)
         return suite;
     else {
         var ts = new TestSuite ("");
         Console.Error.WriteLine (ts.FullName);
         foreach (var i in AssemblyLevel.Cast<NUnitTest> ())
             ts.Add (i);
         return ts;
     }
 }
        public void IgnoredFixtureShouldNotCallFixtureSetUpOrTearDown()
        {
            IgnoredFixture fixture = new IgnoredFixture();
            TestSuite suite = new TestSuite("IgnoredFixtureSuite");
            TestSuite fixtureSuite = TestBuilder.MakeFixture( fixture.GetType() );
            TestMethod testMethod = (TestMethod)fixtureSuite.Tests[0];
            suite.Add( fixtureSuite );

            TestBuilder.RunTestSuite(fixtureSuite, fixture);
            Assert.IsFalse( fixture.setupCalled, "TestFixtureSetUp called running fixture" );
            Assert.IsFalse( fixture.teardownCalled, "TestFixtureTearDown called running fixture" );

            TestBuilder.RunTestSuite(suite, fixture);
            Assert.IsFalse( fixture.setupCalled, "TestFixtureSetUp called running enclosing suite" );
            Assert.IsFalse( fixture.teardownCalled, "TestFixtureTearDown called running enclosing suite" );

            TestBuilder.RunTest(testMethod, fixture);
            Assert.IsFalse( fixture.setupCalled, "TestFixtureSetUp called running a test case" );
            Assert.IsFalse( fixture.teardownCalled, "TestFixtureTearDown called running a test case" );
        }
Example #9
0
 public void TestFixtureMultipleAuthors()
 {
     var suite = new TestSuite("suite");
     suite.Add(TestBuilder.MakeFixture(FixtureType));
     var mockFixtureSuite = (TestSuite)suite.Tests[0];
     Assert.That(mockFixtureSuite.Properties[PropertyNames.Author], Is.EqualTo(
         new[] { "Rob Prouse", "Charlie Poole <*****@*****.**>", "NUnit" }));
 }