/// <summary> /// Method to add test cases to the newly constructed fixture. /// </summary> /// <param name="fixture">The fixture to which cases should be added</param> private void AddTestCasesToFixture(TestFixture fixture) { Type fixtureType = fixture.FixtureType; // TODO: Check this logic added from Neil's build. if (fixtureType.ContainsGenericParameters) { fixture.RunState = RunState.NotRunnable; fixture.Properties.Set(PropertyNames.SkipReason, NO_TYPE_ARGS_MSG); return; } IList methods = fixtureType.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (MethodInfo method in methods) { Test test = BuildTestCase(method, fixture); if (test != null) { fixture.Add(test); } } }
/// <summary> /// Method to add test cases to the newly constructed fixture. /// </summary> private void AddTestCasesToFixture(TestFixture fixture, IPreFilter filter) { // TODO: Check this logic added from Neil's build. if (fixture.TypeInfo.ContainsGenericParameters) { fixture.MakeInvalid(NO_TYPE_ARGS_MSG); return; } var methods = fixture.TypeInfo.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (IMethodInfo method in methods) { if (filter.IsMatch(fixture.TypeInfo.Type, method.MethodInfo)) { Test test = BuildTestCase(method, fixture); if (test != null) { fixture.Add(test); } else // it's not a test, check for disallowed attributes if (method.MethodInfo.HasAttribute <ParallelizableAttribute>(false)) { fixture.MakeInvalid(PARALLEL_NOT_ALLOWED_MSG); } } } }
private void AddTestCases(Type fixtureType) { IList methods = fixtureType.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo item in methods) { Test test = BuildTestCase(item, fixture); if (test != null) { fixture.Add(test); } } }
/// <summary> /// Method to add test cases to the newly constructed fixture. /// </summary> /// <param name="fixtureType"></param> private void AddTestCases(Type fixtureType) { var methods = fixtureType.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (MethodInfo method in methods) { if (_testCaseBuilder.CanBuildFrom(method)) { foreach (var test in _testCaseBuilder.BuildFrom(method, _fixture)) { _fixture.Add(test); } } } }
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); }
void AddTestCases(TestFixture fixture) { var methods = fixture.FixtureType.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (MethodInfo method in methods) { if (!Reflect.HasAttribute(method, typeof(TestAttribute).FullName, true)) { continue; } var test = BuildTestCase(method, fixture); if (test != null) { fixture.Add(test); } } }
/// <summary> /// Method to add test cases to the newly constructed fixture. /// </summary> /// <param name="fixture">The fixture to which cases should be added</param> private void AddTestCasesToFixture(TestFixture fixture) { // TODO: Check this logic added from Neil's build. if (fixture.TypeInfo.ContainsGenericParameters) { fixture.MakeInvalid(NO_TYPE_ARGS_MSG); return; } var methods = fixture.TypeInfo.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (IMethodInfo method in methods) { Test test = BuildTestCase(method, fixture); if (test != null) { fixture.Add(test); } } }
/// <summary> /// Method to add test cases to the newly constructed fixture. /// </summary> private void AddTestCasesToFixture(TestFixture fixture, IPreFilter filter) { // TODO: Check this logic added from Neil's build. if (fixture.TypeInfo.ContainsGenericParameters) { fixture.MakeInvalid(NO_TYPE_ARGS_MSG); return; } // We sort the methods in a deterministic order, since BuildTestCase() will invoke the // Randomizer to create seeds for each test. We want those seeds to be deterministically repeatable // so we can re-run the same conditions by manually fixing the Randomizer.InitialSeed. var methods = new SortedSet <IMethodInfo>(fixture.TypeInfo.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static), MethodInfoComparer.Default); foreach (IMethodInfo method in methods) { // Generate the seed whether or not we use a filter to ensure we invoke the Randomizer to // move to the next random test seed (a test should always get the same seed in the sequence). Test test = BuildTestCase(method, fixture); _randomSeedInitializer.GenerateRandomSeeds(test); if (filter.IsMatch(fixture.TypeInfo.Type, method.MethodInfo)) { if (test != null) { fixture.Add(test); } else // it's not a test, check for disallowed attributes if (method.MethodInfo.HasAttribute <ParallelizableAttribute>(false)) { fixture.MakeInvalid(PARALLEL_NOT_ALLOWED_MSG); } } } }
/// <summary> /// Method to add test cases to the newly constructed fixture. /// </summary> /// <param name="fixture">The fixture to which cases should be added</param> private void AddTestCasesToFixture(TestFixture fixture) { // TODO: Check this logic added from Neil's build. if (fixture.TypeInfo.ContainsGenericParameters) { fixture.RunState = RunState.NotRunnable; fixture.Properties.Set(PropertyNames.SkipReason, NO_TYPE_ARGS_MSG); return; } var methods = fixture.TypeInfo.GetMethods( BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static); foreach (IMethodInfo method in methods) { Test test = BuildTestCase(method, fixture); if (test != null) { fixture.Add(test); } } }