public void WriteCoverageFiles(CoverageData coverage)
        {
            var currentDirectory = Environment.CurrentDirectory;

            CoverageOutputGenerator.WriteHtmlFile(currentDirectory, coverage);
            CoverageOutputGenerator.WriteJsonFile(currentDirectory, coverage);
        }
Beispiel #2
0
        private void RunTests(IEnumerable <string> filePaths, bool openInBrowser = false, bool withCodeCoverage = false, bool withDebugger = false)
        {
            if (!testingInProgress)
            {
                lock (syncLock)
                {
                    if (!testingInProgress)
                    {
                        dte.Documents.SaveAll();
                        var solutionDir = Path.GetDirectoryName(dte.Solution.FullName);
                        testingInProgress = true;

                        Task.Factory.StartNew(
                            () =>
                        {
                            try
                            {
                                // If setttings file environments have not yet been initialized, do so here.
                                if (settingsEnvironments == null || settingsEnvironments.Count == 0)
                                {
                                    InitializeSettingsFileEnvironments();
                                }

                                var options = new TestOptions
                                {
                                    MaxDegreeOfParallelism = Settings.MaxDegreeOfParallelism,
                                    CoverageOptions        = new CoverageOptions
                                    {
                                        Enabled = withCodeCoverage
                                    },

                                    CustomTestLauncher = withDebugger ? new VsDebuggerTestLauncher() : null,
                                    TestLaunchMode     = GetTestLaunchMode(openInBrowser, withDebugger),
                                    ChutzpahSettingsFileEnvironments = settingsEnvironments
                                };
                                var result = testRunner.RunTests(filePaths, options, runnerCallback);

                                if (result.CoverageObject != null)
                                {
                                    var path = CoverageOutputGenerator.WriteHtmlFile(Path.Combine(solutionDir, Constants.CoverageHtmlFileName), result.CoverageObject);
                                    processHelper.LaunchFileInBrowser(path);
                                }
                            }
                            catch (Exception e)
                            {
                                Logger.Log("Error while running tests", "ChutzpahPackage", e);
                            }
                            finally
                            {
                                testingInProgress = false;
                            }
                        });
                    }
                }
            }
        }
Beispiel #3
0
        private void RunTests(IEnumerable <string> filePaths, bool withCodeCoverage, bool openInBrowser)
        {
            if (!testingInProgress)
            {
                lock (syncLock)
                {
                    if (!testingInProgress)
                    {
                        dte.Documents.SaveAll();
                        var solutionDir = Path.GetDirectoryName(dte.Solution.FullName);
                        testingInProgress = true;
                        Task.Factory.StartNew(
                            () =>
                        {
                            try
                            {
                                var options = new TestOptions
                                {
                                    TestFileTimeoutMilliseconds = Settings.TimeoutMilliseconds,
                                    MaxDegreeOfParallelism      = Settings.MaxDegreeOfParallelism,
                                    CoverageOptions             = new CoverageOptions
                                    {
                                        Enabled = withCodeCoverage
                                    },
                                    OpenInBrowser = openInBrowser
                                };
                                var result = testRunner.RunTests(filePaths, options, runnerCallback);

                                if (result.CoverageObject != null)
                                {
                                    var path = CoverageOutputGenerator.WriteHtmlFile(solutionDir, result.CoverageObject);
                                    processHelper.LaunchFileInBrowser(path);
                                }
                            }
                            catch (Exception e)
                            {
                                Logger.Log("Error while running tests", "ChutzpahPackage", e);
                            }
                            finally
                            {
                                testingInProgress = false;
                            }
                        });
                    }
                }
            }
        }
        public override void Transform(TestCaseSummary testFileSummary, string outFile)
        {
            if (testFileSummary == null)
            {
                throw new ArgumentNullException("testFileSummary");
            }

            if (string.IsNullOrEmpty(outFile))
            {
                throw new ArgumentNullException("outFile");
            }

            if (testFileSummary.CoverageObject == null)
            {
                return;
            }

            CoverageOutputGenerator.WriteHtmlFile(outFile, testFileSummary.CoverageObject);
        }
Beispiel #5
0
        public override void TestSuiteFinished(TestCaseSummary testResultsSummary)
        {
            base.TestSuiteFinished(testResultsSummary);

            if (!runContext.IsDataCollectionEnabled || testResultsSummary.CoverageObject == null)
            {
                return;
            }

            try
            {
                // If we do not have a solutiondirectory, we assume that we are running in tfs build
                // In that case we only write to the testrundirectory and do not open a browser
                if (string.IsNullOrEmpty(runContext.SolutionDirectory))
                {
                    ChutzpahTracer.TraceInformation("Chutzpah runs in TFSBuild, writing coverage file to {0}", runContext.TestRunDirectory);

                    var directory = runContext.TestRunDirectory;
                    CoverageOutputGenerator.WriteHtmlFile(directory, testResultsSummary.CoverageObject);
                    CoverageOutputGenerator.WriteJsonFile(directory, testResultsSummary.CoverageObject);
                }
                else
                {
                    ChutzpahTracer.TraceInformation("Chutzpah runs not in TFSBuild opening coverage file in browser");

                    var directory        = runContext.SolutionDirectory;
                    var coverageHtmlFile = CoverageOutputGenerator.WriteHtmlFile(directory, testResultsSummary.CoverageObject);
                    var processHelper    = new ProcessHelper();

                    processHelper.LaunchFileInBrowser(coverageHtmlFile);
                }
            }
            catch (Exception e)
            {
                frameworkHandle.SendMessage(TestMessageLevel.Error, string.Format("Error while writing coverage output: {0}", e));
            }
        }
Beispiel #6
0
        public void WriteCoverageFiles(CoverageData coverage)
        {
            var currentDirectory = Environment.CurrentDirectory;

            CoverageOutputGenerator.WriteHtmlFile(Path.Combine(currentDirectory, Constants.CoverageHtmlFileName), coverage);
        }