コード例 #1
0
ファイル: ScriptSuiteBuilder.cs プロジェクト: carcer/NuScript
        protected TestFixture LoadTestScripts(ScriptSuiteDefinition definition)
        {
            var engine = new Engine(definition.LanguageSetup, definition.EnableDebugging);
            engine.Initialise(definition.ScriptContext);

            var tests = new List<Test>();
            IList<string> scripts = definition.FindScripts();

            var testFixture = new TestFixture(definition.GetType());
            foreach (var script in scripts)
            {
                var test = new ScriptTest(script, engine);
                test.Fixture = testFixture;
                testFixture.Add(test);
            }

            return testFixture;
        }
コード例 #2
0
ファイル: SuiteTestBuilder.cs プロジェクト: i-e-b/FluentBdd
        /// <summary>
        /// Go through the Test tree, building a tree of TestFixures with Test nodes. 
        /// </summary>
        private void MapTestTreeToFixtures(TreeDictionary<string, TestClosure> source, TestSuite container, Type fixtureType)
        {
            foreach (var testClosure in source.Items) {
                container.Add(new ClosureTest(testClosure));
            }

            foreach (var child in source.Children) {
                var fixture = new TestFixture(fixtureType);
                fixture.TestName.Name = child.Key;
                foreach (var testClosure in child.Value.Items) {
                    fixture.Add(new ClosureTest(testClosure));
                }

                foreach (var sub_child in child.Value.Children) {
                    var sub_fixture = new TestFixture(fixtureType);
                    sub_fixture.TestName.Name = sub_child.Key;
                    MapTestTreeToFixtures(sub_child.Value, sub_fixture, fixtureType);
                    fixture.Add(sub_fixture);
                }
                container.Add(fixture);
            }
        }
コード例 #3
0
		/// <summary>
		/// Helper routine that makes a suite from either a TestFixture or
		/// a legacy Suite property.
		/// </summary>
		/// <param name="testType"></param>
		/// <returns></returns>
		private TestSuite MakeSuite( Type testType )
		{
			TestSuite suite = null;

			if(testType != null)
			{
				if( TestFixture.IsValidType( testType ) )
				{
					suite = new TestFixture( testType );
				}
				else if( LegacySuite.IsValidType( testType ) )
				{
					suite = new LegacySuite( testType );
				}
			}
			
			return suite;
		}
コード例 #4
0
 /// <summary>
 /// Find an NUnit test method within a given fixture by name.
 /// </summary>
 /// <param name="fixture"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 private static Test FindTestByName(TestFixture fixture, string name)
 {
     return (from t in fixture.Tests.OfType<Test>()
             where t.TestName.Name == name 
             select t).FirstOrDefault();
 }
コード例 #5
0
        /// <summary>
        /// Find an NUnit test fixture by name.
        /// </summary>
        /// <param name="fixture"></param>
        /// <param name="suite"></param>
        /// <param name="name"></param>
        private static void FindFixtureByName(out TestFixture fixture, TestSuite suite, string name)
        {
            foreach (TestSuite innerSuite in suite.Tests)
            {
                if (innerSuite is TestFixture)
                {
                    if (((TestFixture)innerSuite).TestName.Name == name)
                    {
                        fixture = innerSuite as TestFixture;
                        return;
                    }
                }
                else
                {
                    FindFixtureByName(out fixture, innerSuite, name);
                    if (fixture != null)
                        return;
                }
            }

            fixture = null;
        }
コード例 #6
0
        /// <summary>
        /// Run all tests in a fixture.
        /// </summary>
        /// <param name="fixture">Returns a list of results. These results are usually testcaseType objects.</param>
        /// <returns></returns>
        private IEnumerable<object> RunFixture(TestFixture fixture)
        {
            var results = new List<object>();
            
            foreach (var t in fixture.Tests)
            {
                if (t is ParameterizedMethodSuite)
                {
                    var paramSuite = t as ParameterizedMethodSuite;
                    foreach (var tInner in paramSuite.Tests)
                    {
                        if (tInner is TestMethod)
                        {
                            results.Add(RunTest((TestMethod)tInner));
                        }
                    }
                }
                else if (t is TestMethod)
                {
                    results.Add(RunTest((TestMethod)t));
                }
            }

            return results;
        }