public IEnumerable <TestSuite> BuildFrom(ITypeInfo typeInfo, IPreFilter filter) { Type sourceType = SourceType ?? typeInfo.Type; var fixtureSuite = new ParameterizedFixtureSuite(typeInfo); fixtureSuite.ApplyAttributesToTest(typeInfo.Type.GetTypeInfo()); foreach (ITestFixtureData parms in GetParametersFor(sourceType)) { TestSuite fixture = _builder.BuildFrom(typeInfo, filter, parms); fixtureSuite.Add(fixture); } yield return(fixtureSuite); }
public IEnumerable <TestSuite> BuildFrom(ITypeInfo typeInfo, IPreFilter filter) { // This whole method does more or less the same thing as NUnit's own // TestFixtureSourceAttribute, but with two differences: // 1) this is hard-coded to use the list of test modes as its input // 2) this adds a Category of "fast" when the DirectInvocation mode is used // That second one is important for enabling a quick developer loop. Developers // can create a test playlist that runs only the "fast" tests, or if they have // NCrunch, they can define a custom Engine Mode that automatically runs only // fast tests. These "fast" tests can run without spinning up a new functions // host. Also, because they do not set up an HTTP listener, they can be executed // in parallel without hitting port conflicts. var fixtureSuite = new ParameterizedFixtureSuite(typeInfo); fixtureSuite.ApplyAttributesToTest(typeInfo.Type.GetTypeInfo()); ICustomAttributeProvider assemblyLifeCycleAttributeProvider = typeInfo.Type.GetTypeInfo().Assembly; ICustomAttributeProvider typeLifeCycleAttributeProvider = typeInfo.Type.GetTypeInfo(); foreach (object[] args in FixtureArgs) { var arg = (TestHostModes)args[0]; ITestFixtureData parms = new TestFixtureParameters(new object[] { arg }); TestSuite fixture = this.builder.BuildFrom(typeInfo, filter, parms); switch (arg) { case TestHostModes.DirectInvocation: fixture.Properties["Category"].Add("fast"); fixture.Properties["Category"].Add("parallelizable"); break; case TestHostModes.InProcessEmulateFunctionWithActionResult: fixture.Properties["Category"].Add("fast"); break; } fixture.ApplyAttributesToTest(assemblyLifeCycleAttributeProvider); fixture.ApplyAttributesToTest(typeLifeCycleAttributeProvider); fixtureSuite.Add(fixture); } yield return(fixtureSuite); }
/// <inheritdoc/> public IEnumerable <TestSuite> BuildFrom(ITypeInfo typeInfo, IPreFilter filter) { // This whole method does more or less the same thing as NUnit's own // TestFixtureSourceAttribute, but with one difference: it is hard-coded to use // the list of test modes as its input. var fixtureSuite = new ParameterizedFixtureSuite(typeInfo); fixtureSuite.ApplyAttributesToTest(typeInfo.Type.GetTypeInfo()); ICustomAttributeProvider assemblyLifeCycleAttributeProvider = typeInfo.Type.GetTypeInfo().Assembly; ICustomAttributeProvider typeLifeCycleAttributeProvider = typeInfo.Type.GetTypeInfo(); foreach (object[] args in FixtureArgs) { var arg = (SetupModes)args[0]; ITestFixtureData parms = new TestFixtureParameters(new object[] { arg }); TestSuite fixture = this.builder.BuildFrom(typeInfo, filter, parms); fixture.ApplyAttributesToTest(assemblyLifeCycleAttributeProvider); fixture.ApplyAttributesToTest(typeLifeCycleAttributeProvider); fixtureSuite.Add(fixture); } yield return(fixtureSuite); }