public static TestDomainDependencyGraph BuildGraph( string[] testAssemblies, string[] assemblyPaths, IFixtureFilter fixtureFilter, IRunPipeFilter runPipeFilter, bool verbose ) { // MLS 12/21/05 - adding verbose parameter to fix MBUNIT-28 (verbose command line option not working). // IDEA: A more flexible solution might be to pass in a collection of IRunPipeListeners. if (testAssemblies == null) throw new ArgumentNullException("testAssemblies"); if (testAssemblies.Length == 0) throw new ArgumentException("No assembly to test"); if (fixtureFilter == null) throw new ArgumentNullException("fixtureFilter"); if (runPipeFilter == null) throw new ArgumentNullException("runPipeFilter"); Hashtable loadedAssemblies = new Hashtable(); TestDomainDependencyGraph graph = null; try { graph = new TestDomainDependencyGraph(); graph.verbose = verbose; if (assemblyPaths != null) graph.AssemblyPaths.AddRange(assemblyPaths); foreach (string testAssembly in testAssemblies) { if (loadedAssemblies.Contains(testAssembly)) continue; TestDomain domain = new TestDomain(testAssembly); domain.Filter = fixtureFilter; domain.RunPipeFilter = runPipeFilter; graph.AddDomain(domain); loadedAssemblies.Add(testAssembly, null); } graph.CreateDependencies(); return graph; } catch(Exception ex) { if (graph != null) { graph.Dispose(); graph = null; } throw new ApplicationException("Failed loading assemblies", ex); } }
public void LoadAndRunFixtures() { this.CreateAssembly(); // load assembly using(TestDomain domain = new TestDomain(this.compiler.Parameters.OutputAssembly)) { domain.ShadowCopyFiles = false; domain.InitializeEngine(); foreach (string dir in this.Compiler.Parameters.ReferencedAssemblies) domain.TestEngine.AddHintDirectory(dir); domain.PopulateEngine(); Console.WriteLine("Domain loaded"); Console.WriteLine("Tree populated, {0} tests", domain.TestEngine.GetTestCount()); // Assert.AreEqual(1, domain.TestTree.GetTestCount()); // domain.TestTree.Success+=new MbUnit.Core.RunSuccessEventHandler(TestTree_Success); // running tests domain.TestEngine.RunPipes(); // display report TextReport report = new TextReport(); result = domain.TestEngine.Report.Result; report.Render(result,Console.Out); counter = domain.TestEngine.GetTestCount(); } }