/** * Instantiates an instance of the CxxTestDriverGenerator for the * specified project and test suite collection. * * @param project the ICProject associated with this generator * @param path the path of the source file to be generated * @param suites the collection of test suites to be generated * * @throws IOException if an I/O error occurs during generation */ public TestRunnerGenerator(string path, TestSuiteCollection suites, Dictionary<string, bool> testsToRun) { this.suites = suites; this.runnerPath = path; // Create a proxy object to manage the tests to run. Any tests // not in this map are assumed to be true (so that if tests // have been added, but not refreshed in the tool window, they // will be run until they are explicitly disabled). this.testsToRunProxy = new TestsToRunProxy(testsToRun); // Load the template from the embedded assembly resources. Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream( RunnerTemplateResourcePath); StringTemplateGroup templateGroup = new StringTemplateGroup( new StreamReader(stream), typeof(AngleBracketTemplateLexer)); templateGroup.RegisterAttributeRenderer(typeof(string), new TestRunnerStringRenderer(path)); template = templateGroup.GetInstanceOf("runAllTestsFile"); // Initialize the options that will be passed into the template. options = new Hashtable(); options["platformIsMSVC"] = true; options["trapSignals"] = true; options["traceStack"] = true; options["noStaticInit"] = true; options["root"] = true; options["part"] = false; options["abortOnFail"] = true; options["longLongType"] = null; options["mainProvided"] = suites.MainFunctionExists; options["runner"] = "XmlStdioPrinter"; options["xmlOutput"] = true; options["testResultsFilename"] = Constants.TestResultsFilename; options["testsToRun"] = testsToRunProxy; writer = File.CreateText(path); }
private void PopulateTree(TestSuiteCollection suites) { fixingChecks = true; // Preserve the original selection so that we can reselect them. Dictionary<string, bool> selectedTests = SelectedTestCases; // clear the current contents testsTreeView.Nodes.Clear(); TreeNode solutionNode = new TreeNode(); HierarchyItem solHier = new HierarchyItem(suites.Solution as IVsHierarchy); // Don't do anything if the solution is empty. if (solHier.Name == null) return; solutionNode.Text = "Solution '" + solHier.Name + "'"; solutionNode.ImageKey = solutionNode.SelectedImageKey = "Solution"; testsTreeView.Nodes.Add(solutionNode); foreach(TestSuite suite in suites.Suites) { AddTestSuiteToNode(suite, solutionNode, selectedTests); } fixingChecks = false; testsTreeView.Sort(); solutionNode.ExpandAll(); }
public void RefreshFromSolution() { suites = CxxTestPackage.Instance.AllTestSuites; if (testsTreeView.Created) { testsTreeView.Invoke(new MethodInvoker(delegate() { PopulateTree(suites); })); } }