private MbUnit2AssemblyTest BuildAssemblyTest(Test parent, ICollection <KeyValuePair <Test, string> > unresolvedDependencies) { FixtureExplorer fixtureExplorer = InitializeFixtureExplorer(assembly); IAssemblyInfo assemblyInfo = Reflector.Wrap(assembly); MbUnit2AssemblyTest assemblyTest = new MbUnit2AssemblyTest(fixtureExplorer, assemblyInfo); PopulateAssemblyTestMetadata(assemblyTest, assemblyInfo); foreach (Fixture fixture in fixtureExplorer.FixtureGraph.Fixtures) { MbUnit2Test fixtureTest = CreateFixtureTest(fixture); foreach (RunPipeStarter starter in fixture.Starters) { MbUnit2Test test = CreateTest(starter.Pipe); fixtureTest.AddChild(test); } assemblyTest.AddChild(fixtureTest); } foreach (string assemblyName in fixtureExplorer.GetDependentAssemblies()) { unresolvedDependencies.Add(new KeyValuePair <Test, string>(assemblyTest, assemblyName)); } parent.AddChild(assemblyTest); return(assemblyTest); }
private static MbUnit2Test CreateFixtureTest(Fixture fixture) { ITypeInfo fixtureType = Reflector.Wrap(fixture.Type); MbUnit2Test test = new MbUnit2Test(fixtureType.Name, fixtureType, fixture, null); test.Kind = TestKinds.Fixture; MbUnit2MetadataUtils.PopulateFixtureMetadata(test, fixtureType); return(test); }
private static MbUnit2Test CreateTest(RunPipe runPipe) { IMemberInfo member = GuessMemberInfoFromRunPipe(runPipe); ICodeElementInfo codeElement = member ?? Reflector.Wrap(runPipe.FixtureType); MbUnit2Test test = new MbUnit2Test(runPipe.ShortName, codeElement, runPipe.Fixture, runPipe); test.Kind = TestKinds.Test; test.IsTestCase = true; if (member != null) { MbUnit2MetadataUtils.PopulateTestMetadata(test, member); } return(test); }
private static MbUnit2Test CreateTest(RunPipe runPipe) { IMemberInfo member = GuessMemberInfoFromRunPipe(runPipe); ICodeElementInfo codeElement = member ?? Reflector.Wrap(runPipe.FixtureType); MbUnit2Test test = new MbUnit2Test(runPipe.ShortName, codeElement, runPipe.Fixture, runPipe); test.Kind = TestKinds.Test; test.IsTestCase = true; if (member != null) MbUnit2MetadataUtils.PopulateTestMetadata(test, member); return test; }
private static MbUnit2Test CreateFixtureTest(Fixture fixture) { ITypeInfo fixtureType = Reflector.Wrap(fixture.Type); MbUnit2Test test = new MbUnit2Test(fixtureType.Name, fixtureType, fixture, null); test.Kind = TestKinds.Fixture; MbUnit2MetadataUtils.PopulateFixtureMetadata(test, fixtureType); return test; }
private void Initialize() { progressMonitor.Canceled += HandleCanceled; progressMonitor.SetStatus(Resources.MbUnit2TestController_InitializingMbUnitTestRunner); int totalWork = 1; if (fixtureExplorer.HasAssemblySetUp) { totalWork += 1; } if (fixtureExplorer.HasAssemblyTearDown) { totalWork += 1; } // Build a reverse mapping from types and run-pipes to tests. includedFixtureTypes = new HashSet <Type>(); fixtureTestCommands = new Dictionary <Fixture, ITestCommand>(); runPipeTestCommands = new Dictionary <RunPipe, ITestCommand>(); activeTestContexts = new Dictionary <ITestCommand, ITestContext>(); bool isExplicit = false; foreach (ITestCommand testCommand in testCommands) { if (testCommand.IsExplicit) { isExplicit = true; } MbUnit2Test test = (MbUnit2Test)testCommand.Test; Fixture fixture = test.Fixture; RunPipe runPipe = test.RunPipe; if (fixture == null) { assemblyTestCommand = testCommand; } else if (runPipe == null) { includedFixtureTypes.Add(fixture.Type); fixtureTestCommands[fixture] = testCommand; if (fixture.HasSetUp) { totalWork += 1; } if (fixture.HasTearDown) { totalWork += 1; } } else { runPipeTestCommands[runPipe] = testCommand; totalWork += 1; } } // Set options IsExplicit = isExplicit; FixtureFilter = this; RunPipeFilter = this; workUnit = 1.0 / totalWork; progressMonitor.Worked(workUnit); }