コード例 #1
0
ファイル: TestExecutor.cs プロジェクト: mdaniyalkhan/MuTest
        private void ProcessOnOutputDataReceived(object sender, DataReceivedEventArgs args)
        {
            lock (OutputDataReceivedLock)
            {
                if (args.Data != null && args.Data.EndsWith(CoverageExtension))
                {
                    var coverageFile = args.Data.Trim();
                    if (File.Exists(coverageFile))
                    {
                        using (CoverageInfo info = CoverageInfo.CreateFromFile(
                                   coverageFile,
                                   new[]
                        {
                            Path.GetDirectoryName(_testClassLibrary)
                        },
                                   new[]
                        {
                            Path.GetDirectoryName(_testClassLibrary)
                        }))
                        {
                            CodeCoverage = info.BuildDataSet();
                        }
                    }
                }

                OnThresholdReached(args);

                if (KillProcessOnTestFail && args.Data != null &&
                    (args.Data.StartsWith(FailedDuringExecution) ||
                     args.Data.StartsWith(ErrorDuringExecution)))
                {
                    LastTestExecutionStatus = TestExecutionStatus.Failed;

                    var process = (Process)sender;
                    KillProcess(process);
                }
            }
        }
コード例 #2
0
        public static int Main(string[] args)
        {
            if (args == null || args.Length == 0)
            {
                DisplayUsage();
                return(0);
            }

            try
            {
                Arguments.Default = ArgumentProperties.Parse(args);

                if (!File.Exists(Arguments.DataCoverageFile))
                {
                    return(0);
                }

                using (CoverageInfo info = CoverageInfo.CreateFromFile(Arguments.DataCoverageFile))
                {
                    CoverageDS data = info.BuildDataSet();

                    string outputXml = Transform(data.GetXml());

                    XDocument doc = XDocument.Parse(outputXml);
                    ShortenMethodNames(doc);
                    File.WriteAllText(Arguments.XmlCoverageFile, doc.ToString());
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.ToString());
                return(1);
            }

            return(0);
        }
コード例 #3
0
        public ProjectElement Parse(String[] inputfiles)
        {
            ProjectElement PROJECT = new ProjectElement("new_project", 123323230);

            // Open file
            using (CoverageInfo info = JoinCoverageFiles(inputfiles))
            {
                CoverageDS dataSet = info.BuildDataSet();

                Dictionary <String, PackageElement> packages = new Dictionary <String, PackageElement>();
                Dictionary <uint, FileElement>      files    = new Dictionary <uint, FileElement>();

                // Namespaces
                DataTable namespacesTable = dataSet.Tables["NameSpaceTable"];
                DataTable classesTable    = dataSet.Tables["Class"];
                DataTable filesTable      = dataSet.Tables["SourceFileNames"];

                CreateIndexPackages(PROJECT, namespacesTable, packages);
                CreateIndexFiles(filesTable, files);

                foreach (DataRow iclass in classesTable.Rows)
                {
                    DataRow[] childRows = iclass.GetChildRows("Class_Method");

                    // Since it's one class per file (at least) declare
                    // file here and add it to the class.
                    uint fileid = 0;
                    // uint classlocs = 0;
                    uint        covered_methods = 0;
                    FileElement fe = null;

                    foreach (DataRow imethod in childRows)
                    {
                        // Method starting line
                        uint linenum = 0;
                        // Get First Line in class
                        DataRow[] childRows2 = imethod.GetChildRows("Method_Lines");
                        //if(childRows2.Length > 0)
                        foreach (DataRow iline in childRows2)
                        {
                            LineElement le       = null;
                            uint        coverage = iline.Field <uint>("Coverage");
                            if (linenum == 0)
                            {
                                fileid = iline.Field <uint>("SourceFileID");
                                string methodname = System.Security.SecurityElement.Escape((string)imethod["MethodName"]);
                                linenum = iline.Field <uint>("LnStart");
                                le      = new LineElement(linenum, "method", methodname, coverage);
                            }
                            else
                            {
                                linenum = iline.Field <uint>("LnStart");
                                le      = new LineElement(linenum, "stmt", "", coverage);
                            }

                            // If the file doesn't exists in our report, we'll
                            // just ignore this information
                            if (files.ContainsKey(fileid))
                            {
                                fe = files[fileid];
                                fe.AddLine(le);
                            }
                        }

                        // Count how many methods covered we have
                        if ((uint)imethod["LinesCovered"] > 0)
                        {
                            covered_methods++;
                        }
                    }

                    uint totallines           = (uint)iclass["LinesCovered"] + (uint)iclass["LinesNotCovered"] + (uint)iclass["LinesPartiallyCovered"];
                    uint complexity           = 1;
                    uint methods              = (uint)childRows.Length;
                    uint statements           = totallines - methods;
                    uint covered_statements   = (uint)iclass["LinesCovered"] - covered_methods;
                    uint conditionals         = 0;
                    uint covered_conditionals = 0;

                    ClassElement ce = new ClassElement(System.Security.SecurityElement.Escape((string)iclass["ClassName"]));
                    ce.Metrics = new ClassMetrics(complexity, statements, covered_statements, conditionals, covered_conditionals, methods, covered_methods);

                    if (fe != null)
                    {
                        if (!fe.GetClasses().Contains(ce))
                        {
                            fe.AddClass(ce);
                        }

                        if (packages.ContainsKey((string)iclass["NamespaceKeyName"]))
                        {
                            PackageElement pe = packages[(string)iclass["NamespaceKeyName"]];
                            if (!pe.GetFiles().Contains(fe))
                            {
                                pe.AddFile(fe);
                            }
                        }
                    }
                }
            }
            return(PROJECT);
        }
コード例 #4
0
ファイル: coverage_analyser.cs プロジェクト: tsal/Principia
            private static void Main(string[] args)
            {
                Int64         lines_covered                 = 0;
                Int64         lines_partially_covered       = 0;
                Int64         lines_not_covered             = 0;
                string        breakdown_percent_not_covered = "";
                string        breakdown_lines_not_covered   = "";
                string        unit_names = "";
                DirectoryInfo directory  = new DirectoryInfo(args[0]);

                Console.WriteLine(directory.FullName);
                FileInfo[] files = directory.GetFiles("*.coverage");
                foreach (FileInfo file in files)
                {
                    Console.WriteLine("Analysing " + file.Name);
                    Regex  file_regex  = new Regex(@"^(.+?)(_tests?)+.exe.coverage");
                    Match  file_match  = file_regex.Match(file.Name);
                    string tested_unit = file_match.Groups[1].ToString();
                    Regex  regex;
                    if (tested_unit == "ksp_plugin")
                    {
                        Console.WriteLine("Covering principia::" + tested_unit +
                                          " as well as extern \"C\" interface functions" +
                                          " (of the form ::principia__Identifier)");
                        regex = new Regex("^principia(::" + tested_unit + "|__)");
                    }
                    else
                    {
                        Console.WriteLine("Covering principia::" + tested_unit);
                        regex = new Regex("^principia::" + tested_unit);
                    }
                    Regex ignored_files_regex =
                        new Regex(@"((_test\.cpp|" +
                                  @"\.generated\.cc|" +
                                  @"\.generated\.h|" +
                                  @"\.pb\.h|" +
                                  @"\.pb\.cc)$|" +
                                  @"\\mock_)");
                    var covered = new Dictionary <CodeLine, UInt32>();
                    using (CoverageInfo info = CoverageInfo.CreateFromFile(file.FullName)) {
                        CoverageDS dataset = info.BuildDataSet();
                        foreach (CoverageDSPriv.LinesRow lines in dataset.Lines)
                        {
                            if (regex.Match(lines.MethodRow.MethodName).Success&&
                                !ignored_files_regex.Match(
                                    dataset.GetSourceFileName(lines)).Success)
                            {
                                var code_line = new CodeLine {
                                    file        = dataset.GetSourceFileName(lines),
                                    line_number = lines.LnStart
                                };
                                if (lines.LnStart != lines.LnEnd)
                                {
                                    Console.WriteLine("lines.LnStart != lines.LnEnd");
                                    return;
                                }
                                if (covered.ContainsKey(code_line))
                                {
                                    covered[code_line] = Math.Min(covered[code_line], lines.Coverage);
                                }
                                else
                                {
                                    covered.Add(code_line, lines.Coverage);
                                }
                            }
                        }
                    }
                    Int64 subtotal_lines       = covered.Count;
                    Int64 subtotal_not_covered = 0;
                    foreach (var pair in covered)
                    {
                        if (pair.Value > 1)
                        {
                            ++subtotal_not_covered;
                            ++lines_not_covered;
                            Console.WriteLine(pair.Key.file + ":" + pair.Key.line_number);
                        }
                        else if (pair.Value == 1)
                        {
                            ++lines_partially_covered;
                        }
                        else
                        {
                            ++lines_covered;
                        }
                    }
                    CommaSeparatedAppend(ref breakdown_lines_not_covered,
                                         subtotal_not_covered.ToString());
                    CommaSeparatedAppend(
                        ref breakdown_percent_not_covered,
                        (((double)subtotal_not_covered / (double)subtotal_lines) *
                         100.0).ToString());
                    CommaSeparatedAppend(ref unit_names, tested_unit);
                }
                Int64 total = lines_partially_covered + lines_covered + lines_not_covered;

                Console.WriteLine("Covered      : " +
                                  ValueAndPercentage(lines_partially_covered +
                                                     lines_covered, total));
                Console.WriteLine("  Partially  : " +
                                  ValueAndPercentage(lines_partially_covered, total));
                Console.WriteLine("  Completely : " +
                                  ValueAndPercentage(lines_covered, total));
                Console.WriteLine("Not Covered  : " +
                                  ValueAndPercentage(lines_not_covered, total));
                File.WriteAllText(
                    Path.Combine(directory.FullName, "jenkins_percent_coverage.csv"),
                    "not covered, partially covered, fully covered\n" +
                    ((double)lines_not_covered / (double)total) * 100.0 + ", " +
                    ((double)lines_partially_covered / (double)total) * 100.0 + ", " +
                    ((double)lines_covered / (double)total) * 100.0);
                File.WriteAllText(
                    Path.Combine(directory.FullName, "jenkins_lines_coverage.csv"),
                    "not covered, partially covered, fully covered\n" +
                    lines_not_covered + ", " +
                    lines_partially_covered + ", " +
                    lines_covered);
                File.WriteAllText(
                    Path.Combine(directory.FullName,
                                 "jenkins_lines_coverage_breakdown.csv"),
                    unit_names + "\n" + breakdown_lines_not_covered);
                File.WriteAllText(
                    Path.Combine(directory.FullName,
                                 "jenkins_percent_coverage_breakdown.csv"),
                    unit_names + "\n" + breakdown_percent_not_covered);
            }
コード例 #5
0
        /// <summary>
        /// Main process
        /// </summary>
        /// <param name="args">Command Line Arguments</param>
        static void Main(string[] args)
        {
            bool result = false;

            try
            {
                // cosole write header.
                ConsoleWriteHeader();

                if (IsConsoleWriteHelp(args))
                {
                    ConsoleWriteHelp();
                    return;
                }

                string inputPath  = ConvertArg(args, ARGS_PREFIX_INPUT_PATH);
                string outputPath = ConvertArg(args, ARGS_PREFIX_OUTPUT_PATH);
                string symbolsDir = ConvertArg(args, ARGS_PREFIX_SYMBOLS_DIR);
                string exeDir     = ConvertArg(args, ARGS_PREFIX_EXE_DIR);
                string xslPath    = ConvertArg(args, ARGS_PREFIX_XSL_PATH);
                string tmpPath    = Path.Combine(".\\", FILE_NAME_WORK);

                if (!CreateWorkFile(tmpPath, inputPath))
                {
                    return;
                }

                IList <string> symPaths = new List <string>();
                IList <string> exePaths = new List <string>();

                if (!string.IsNullOrWhiteSpace(symbolsDir))
                {
                    symPaths.Add(symbolsDir);
                }

                if (!string.IsNullOrWhiteSpace(exeDir))
                {
                    exePaths.Add(exeDir);
                }

                CoverageInfo ci   = CoverageInfo.CreateFromFile(tmpPath, exePaths, symPaths);
                CoverageDS   data = ci.BuildDataSet(null);

                string outputWk = outputPath;
                if (string.IsNullOrEmpty(outputWk))
                {
                    outputWk = Path.ChangeExtension(inputPath, "xml");
                }

                Console.WriteLine("output file: {0}", outputWk);

                if (string.IsNullOrEmpty(xslPath))
                {
                    data.ExportXml(outputWk);
                }
                else
                {
                    WriteTransformXml(data, outputWk, xslPath);
                }

                result = true;

                Console.WriteLine("convert success.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Environment.Exit((result) ? (0) : (1));
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: zarkara/CoverageConverter
        /// <summary>
        /// Main process
        /// </summary>
        /// <param name="args">Command Line Arguments</param>
        static void Main(string[] args)
        {
            bool result = false;

            try
            {
                // cosole write header.
                ConsoleWriteHeader();

                if (IsConsoleWriteHelp(args))
                {
                    ConsoleWriteHelp();
                    return;
                }

                string inputPath  = ConvertArg(args, ARGS_PREFIX_INPUT_PATH);
                string outputPath = ConvertArg(args, ARGS_PREFIX_OUTPUT_PATH);
                string symbolsDir = ConvertArg(args, ARGS_PREFIX_SYMBOLS_DIR);
                string exeDir     = ConvertArg(args, ARGS_PREFIX_EXE_DIR);
                string xslPath    = ConvertArg(args, ARGS_PREFIX_XSL_PATH);

                if (!File.Exists(inputPath))
                {
                    Console.WriteLine("input file not found. ({0})", inputPath);
                    return;
                }

                Console.WriteLine("input file: {0}", inputPath);

                string inputDir = Path.GetDirectoryName(inputPath);
                CoverageInfoManager.SymPath = (string.IsNullOrEmpty(symbolsDir)) ? (inputDir) : (symbolsDir);
                CoverageInfoManager.ExePath = (string.IsNullOrEmpty(exeDir)) ? (inputDir) : (exeDir);

                CoverageInfo ci   = CoverageInfoManager.CreateInfoFromFile(inputPath);
                CoverageDS   data = ci.BuildDataSet(null);

                string outputWk = outputPath;
                if (string.IsNullOrEmpty(outputWk))
                {
                    outputWk = Path.ChangeExtension(inputPath, "xml");
                }

                Console.WriteLine("output file: {0}", outputWk);

                if (string.IsNullOrEmpty(xslPath))
                {
                    data.WriteXml(outputWk);
                }
                else
                {
                    WriteTransformXml(data, outputWk, xslPath);
                }

                result = true;

                Console.WriteLine("convert success.");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Environment.Exit((result) ? (0) : (1));
            }
        }
コード例 #7
0
        private static void WriteCoverageOutputAsXml(CoverageInfo coverageInfo, string coverageOutputXmlFilename)
        {
            CoverageDS data = coverageInfo.BuildDataSet(null);

            data.ExportXml(coverageOutputXmlFilename);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: etinquis/Duvet
        private static void Main(string[] args)
        {
            string coverageFile = args[0];
            // Create a coverage info object from the file

            CoverageInfo ci = CoverageInfo.CreateFromFile(coverageFile);

            CoverageDS summary = ci.BuildDataSet(null);

            BigInteger coveredBlocks = 0;
            BigInteger coveredLines  = 0;

            BigInteger totalBlocks = 0;
            BigInteger totalLines  = 0;

            DirectoryInfo htmlRoot = new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "CoverageReport"));// Directory.CreateDirectory("html");

            htmlRoot.Create();

            CoverageDsParser parser = new CoverageDsParser(coverageFile);

            TeamCityHtmlReport report = new TeamCityHtmlReport(parser.Assemblies);

            report.WriteTo(htmlRoot);


            //foreach (CoverageDSPriv.SourceFileNamesRow fileRow in summary.SourceFileNames)
            //{
            //    int currentLineNumber = 1;

            //    FileInfo info = new FileInfo(fileRow.SourceFileName);

            //    StreamReader fileReader = new StreamReader(info.FullName);
            //    StringBuilder builder = new StringBuilder();
            //    builder.Append("<html id=\"htmlId\">");
            //    builder.Append("<head>");
            //    builder.AppendFormat("<title>{0}</title>", "Coverage Report > " + fileRow.SourceFileName);
            //    builder.AppendFormat("<style type=\"text/css\">{0}</style>",
            //                         "@import \"../../../.css/coverage.css\"; @import \"../../../.css/idea.css\";");
            //    builder.AppendFormat("<script type=\"text/javascript\" src=\"../../../.js/highlight.pack.js\"></script>");
            //    builder.Append("</head>");
            //    builder.Append("<body>");

            //    string sourceType = "cpp";

            //    if (info.Extension == ".cpp" || info.Extension == ".h")
            //    {

            //    } else if (info.Extension == ".cs")
            //    {
            //        sourceType = "cs";
            //    }

            //    builder.AppendFormat("<pre><div class=\"sourceCode {0}\" id=\"sourceCode\"", sourceType);

            //    CoverageDSPriv.SourceFileNamesRow row = fileRow;
            //    foreach (CoverageDSPriv.LinesRow lineRow in summary.Lines.Where(line=>line.SourceFileID == row.SourceFileID).OrderBy(line=>line.LnStart))
            //    {
            //        while (currentLineNumber < lineRow.LnStart)
            //        {
            //            builder.AppendFormat("<i class=\"no-highlight\">{0}</i>&nbsp;{1}" + Environment.NewLine, currentLineNumber++, fileReader.ReadLine());
            //        }

            //        string cssClass = "nc";

            //        switch (lineRow.Coverage)
            //        {
            //            case 1:
            //                cssClass = "pc";
            //                break;
            //            case 2:
            //                cssClass = "nc";
            //                break;
            //            default:
            //                cssClass = "fc";
            //                break;
            //        }

            //        builder.AppendFormat(
            //            "<b class=\"{2}\"><i class=\"no-highlight\">{0}</i>&nbsp;{1}</b>" + Environment.NewLine,
            //            currentLineNumber++, fileReader.ReadLine(),
            //            cssClass);
            //    }

            //    while (fileReader.Peek() != -1)
            //    {
            //        builder.AppendFormat("<i class=\"no-highlight\">{0}</i>&nbsp;{1}" + Environment.NewLine, currentLineNumber++, fileReader.ReadLine());
            //    }
            //    builder.Append("</pre></div>");
            //    builder.AppendFormat("<script type=\"text/javascript\">{0}</script>", "(function() {var codeBlock = document.getElementById('sourceCode');if (codeBlock) {hljs.highlightBlock(codeBlock);}})();");
            //    builder.Append("</body>");
            //    builder.Append("</html>");

            //    string html = builder.ToString();
            //    StreamWriter writer = new StreamWriter(Path.Combine(htmlRoot.FullName, new FileInfo(fileRow.SourceFileName).Name + ".html"));
            //    writer.Write(html);
            //    writer.Close();
            //}

            foreach (CoverageDSPriv.ModuleRow moduleRow in summary.Module.Rows)
            {
                BigInteger blocksCovered    = moduleRow.BlocksCovered;
                BigInteger blocksNotCovered = moduleRow.BlocksNotCovered;

                coveredBlocks += blocksCovered;
                totalBlocks   += blocksCovered + blocksNotCovered;

                BigInteger linesCovered          = moduleRow.LinesCovered;
                BigInteger linesPartiallyCovered = moduleRow.LinesPartiallyCovered;
                BigInteger linesNotCovered       = moduleRow.LinesNotCovered;

                coveredLines += linesCovered + linesPartiallyCovered;
                totalLines   += linesCovered + linesPartiallyCovered + linesNotCovered;
            }

            BigInteger coveredMethods = 0;
            BigInteger totalMethods   = summary.Method.Rows.Count;

            foreach (CoverageDSPriv.MethodRow methodRow in summary.Method.Rows)
            {
                float coverage = (methodRow.LinesCovered + methodRow.LinesPartiallyCovered) /
                                 (methodRow.LinesCovered + methodRow.LinesPartiallyCovered + (float)methodRow.LinesNotCovered);
                coveredMethods += (coverage > MethodCoverageThreshold) ? 1 : 0;
            }

            float blockCoverage  = totalBlocks == 0 ? 0 : ((uint)((coveredBlocks * TwoDecimalPlaces) / totalBlocks)) / 10000f;
            float lineCoverage   = totalLines == 0 ? 0 : ((uint)((coveredLines * TwoDecimalPlaces) / totalLines)) / 10000f;
            float methodCoverage = totalMethods == 0 ? 0 : ((uint)((coveredMethods * TwoDecimalPlaces) / totalMethods)) / 10000f;

            XmlDocument doc         = new XmlDocument();
            XmlElement  rootElement = doc.CreateElement("build");

            XmlElement blockCoverageNode  = CreateBlockCoverageElement(doc, blockCoverage);
            XmlElement lineCoverageNode   = CreateLineCoverageElement(doc, lineCoverage);
            XmlElement methodCoverageNode = CreateMethodCoverageElement(doc, methodCoverage);

            XmlElement totalCoveredLinesNode = CreateCoveredLinesElement(doc, (uint)coveredLines);
            XmlElement totalLinesNode        = CreateTotalLinesElement(doc, (uint)totalLines);

            XmlElement totalCoveredMethodsNode = CreateCoveredMethodsElement(doc, (uint)coveredMethods);
            XmlElement totalMethodsNode        = CreateTotalMethodsElement(doc, (uint)totalMethods);

            rootElement.AppendChild(blockCoverageNode);
            rootElement.AppendChild(lineCoverageNode);
            rootElement.AppendChild(methodCoverageNode);

            rootElement.AppendChild(totalCoveredLinesNode);
            rootElement.AppendChild(totalLinesNode);

            rootElement.AppendChild(totalCoveredMethodsNode);
            rootElement.AppendChild(totalMethodsNode);

            doc.AppendChild(rootElement);
            using (var writer = new StreamWriter("teamcity-info.xml"))
            {
                writer.Write(doc.OuterXml);
            }
        }
コード例 #9
0
ファイル: TestExecutor.cs プロジェクト: mdaniyalkhan/MuTest
        public async Task ExecuteTests(IList <MethodDetail> selectedMethods)
        {
            if (selectedMethods == null && string.IsNullOrWhiteSpace(FullyQualifiedName))
            {
                throw new ArgumentNullException(nameof(selectedMethods));
            }

            try
            {
                EnableTimeout           = EnableTimeout && string.IsNullOrWhiteSpace(BaseAddress);
                _currentDateTime        = DateTime.Now;
                LastTestExecutionStatus = TestExecutionStatus.Success;
                TestResult = null;
                var testResultFile = $@"""{_settings.TestsResultDirectory}report_{_currentDateTime:yyyyMdhhmmss}.trx""";
                var methodBuilder  = new StringBuilder(_settings.Blame);

                if (EnableCustomOptions)
                {
                    methodBuilder.Append(_settings.Options);
                }

                if (EnableParallelTestExecution)
                {
                    methodBuilder.Append(_settings.ParallelTestExecution);
                }

                if (X64TargetPlatform)
                {
                    methodBuilder.Append(" /Platform:x64");
                }

                methodBuilder
                .Append(_settings.SettingsOption)
                .Append($@"""{_settings.RunSettingsPath}""");

                if (EnableLogging)
                {
                    methodBuilder.Append(_settings.LoggerOption.Replace("{0}", testResultFile));
                }

                if (string.IsNullOrWhiteSpace(FullyQualifiedName))
                {
                    var methodDetails = selectedMethods.ToList();
                    methodBuilder.Append(_settings.TestsOption);
                    foreach (var method in methodDetails)
                    {
                        methodBuilder
                        .Append($"{method.Method.Class().ClassName()}.{method.Method.MethodName()}")
                        .Append(CommaSeparator);
                    }
                }
                else
                {
                    methodBuilder.Append(TestCaseFilter)
                    .Append("\"")
                    .Append("FullyQualifiedName~")
                    .Append(FullyQualifiedName)
                    .Append("\"");
                }

                methodBuilder.Append($@" ""{_testClassLibrary}""");

                OnBeforeTestExecuted(methodBuilder.ToString());

                if (string.IsNullOrWhiteSpace(BaseAddress))
                {
                    var processInfo = new ProcessStartInfo(_settings.VSTestConsolePath)
                    {
                        Arguments              = methodBuilder.ToString(),
                        UseShellExecute        = false,
                        CreateNoWindow         = true,
                        RedirectStandardOutput = true,
                        RedirectStandardError  = true
                    };

                    await Task.Run(() =>
                    {
                        lock (TestTimeoutLock)
                        {
                            using (_currentProcess = new Process
                            {
                                StartInfo = processInfo,
                                EnableRaisingEvents = true
                            })
                            {
                                _currentProcess.OutputDataReceived += ProcessOnOutputDataReceived;
                                _currentProcess.ErrorDataReceived  += ProcessOnOutputDataReceived;
                                _currentProcess.Start();
                                _currentProcess.BeginOutputReadLine();
                                _currentProcess.BeginErrorReadLine();

                                if (EnableTimeout)
                                {
                                    _currentProcess.WaitForExit(_settings.TestTimeout);
                                    KillProcess(_currentProcess);
                                }
                                else
                                {
                                    _currentProcess.WaitForExit();
                                }

                                if (LastTestExecutionStatus != TestExecutionStatus.Failed &&
                                    LastTestExecutionStatus != TestExecutionStatus.Timeout)
                                {
                                    LastTestExecutionStatus = TestStatusList[_currentProcess.ExitCode];
                                }

                                _currentProcess.OutputDataReceived -= ProcessOnOutputDataReceived;
                                _currentProcess.ErrorDataReceived  -= ProcessOnOutputDataReceived;
                            }
                        }
                    });

                    if (EnableLogging)
                    {
                        GetTestResults(testResultFile);
                    }
                }
                else
                {
                    try
                    {
                        using (var client = new HttpClient())
                        {
                            client.DefaultRequestHeaders.Accept.Add(
                                new MediaTypeWithQualityHeaderValue("application/json"));
                            var content = new FormUrlEncodedContent(new[]
                            {
                                new KeyValuePair <string, string>(nameof(TestInput.Arguments), methodBuilder.ToString()),
                                new KeyValuePair <string, string>(nameof(TestInput.KillProcessOnTestFail), KillProcessOnTestFail.ToString())
                            });

                            client.Timeout = Timeout.InfiniteTimeSpan;
                            var response = await client.PostAsync($"{BaseAddress}api//mutest/test", content);

                            if (response.IsSuccessStatusCode)
                            {
                                OutputDataReceived?.Invoke(this, $"MuTest Test Service is executing tests at {BaseAddress}\n");
                                var responseData = await response.Content.ReadAsStringAsync();

                                var result = JsonConvert.DeserializeObject <TestResult>(responseData);
                                OutputDataReceived?.Invoke(this, result.TestOutput);
                                LastTestExecutionStatus = result.Status;

                                if (!string.IsNullOrWhiteSpace(result.CoveragePath) && File.Exists(result.CoveragePath))
                                {
                                    using (CoverageInfo info = CoverageInfo.CreateFromFile(
                                               result.CoveragePath,
                                               new[]
                                    {
                                        Path.GetDirectoryName(_testClassLibrary)
                                    },
                                               new[]
                                    {
                                        Path.GetDirectoryName(_testClassLibrary)
                                    }))
                                    {
                                        CodeCoverage = info.BuildDataSet();
                                    }
                                }
                            }
                            else
                            {
                                LastTestExecutionStatus = TestExecutionStatus.Timeout;
                                Trace.TraceError("MuTest Test Service not Found at {0}", BaseAddress);
                                OutputDataReceived?.Invoke(this, $"MuTest Test Service is not running at {BaseAddress}\n");
                            }
                        }

                        if (EnableLogging)
                        {
                            GetTestResults(testResultFile);
                        }
                    }
                    catch (Exception exp)
                    {
                        Trace.TraceError("MuTest Test Service not Found at {0}. Unable to Test Product {1}", BaseAddress, exp);
                        OutputDataReceived?.Invoke(this, $"MuTest Test Service is not running at {BaseAddress}\n");
                        LastTestExecutionStatus = TestExecutionStatus.Timeout;
                    }
                }
            }
            catch (Exception e)
            {
                Trace.TraceError("{0} - {1}", e.Message, e);
                throw;
            }
        }