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);
                }));
            }
        }
        // ------------------------------------------------------
        /// <summary>
        /// Creates the test runner source file for the current startup
        /// project and adds it to the project.
        /// </summary>
        /// <param name="doNotRunTests">
        /// If true, the file will be generated but will not include any
        /// statements to run any tests. If false, the tests will be run
        /// based on the current selection in the CxxTest Suites view.
        /// </param>
        public void CreateTestRunnerFile(bool doNotRunTests)
        {
            TestSuiteCollection suites = AllTestSuites;

            Dictionary <string, bool> testsToRun;

            if (doNotRunTests)
            {
                testsToRun = null;
            }
            else
            {
                testsToRun = TryToGetTestsToRun();
            }

            HierarchyItem startupProject =
                VsShellUtils.GetStartupProject(this);

            string projectDir = startupProject.ProjectDirectory;
            string workingDir = GetActiveWorkingDirectory(startupProject);

            Project project = startupProject.GetExtObjectAs <Project>();

            string runnerPath = Path.Combine(
                projectDir, Constants.TestRunnerFilename);

            // Remove the file from the project if necessary, and delete it
            // from the file system if it exists.
            VCProject vcproj = (VCProject)project.Object;

            if (!vcproj.CanAddFile(runnerPath))
            {
                IVCCollection coll = (IVCCollection)vcproj.Files;
                vcproj.RemoveFile(coll.Item(Constants.TestRunnerFilename));
            }

            if (File.Exists(runnerPath))
            {
                File.Delete(runnerPath);
            }

            TestRunnerGenerator generator =
                new TestRunnerGenerator(runnerPath, suites, testsToRun);

            generator.Generate();

            // Add the file to the project.

            vcproj.AddFile(runnerPath);
        }
Exemple #4
0
        /**
         * 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);
        }
Exemple #5
0
 internal DateTimeTestSuite(TestSuiteCollection parent) : base(parent)
 {
 }
 public static DateTimeTestSuite DateTime(this TestSuiteCollection _this) => new DateTimeTestSuite(_this);