protected override Task <int> Execute() { CloverReport.Execute(CoverageLoadedFileOption.GetValue(), CloverOutputOption.GetValue(), ThresholdOption.GetValue()); var result = CalcUtils.IsHigherThanThreshold(CoverageLoadedFileOption.GetValue(), ThresholdOption.GetValue()); return(Task.FromResult(result)); }
protected override Task <int> Execute() { CloverReport.Execute(_coverageLoadedFileOption.Result, _cloverOutputOption.Value, _thresholdOption.Value); var result = CalcUtils.IsHigherThanThreshold(_coverageLoadedFileOption.Result, _thresholdOption.Value); return(Task.FromResult(result)); }
static void Main(string[] args) { // Parse arguments var options = new Options(); var parser = new CommandLineParser(new CommandLineParserSettings(Console.Error)); if (!parser.ParseArguments(args, options)) { Environment.Exit(1); } // Coverage file parser MikeParser mikeParser = new MikeParser(); foreach (String s in options.IncludedNamespaces) { mikeParser.IncludeNamespace(s); } foreach (String s in options.ExcludedNamespaces) { mikeParser.ExcludeNamespace(s); } foreach (String s in options.IncludedFiles) { mikeParser.IncludeFile(s); } foreach (String s in options.ExcludedFiles) { mikeParser.ExcludeFile(s); } // Parse coverage file ProjectElement pe = mikeParser.Parse(options.InputFiles); // Generate clover report if (options.CloverOutput != null) { CloverReport cloverreport = new CloverReport(); using (StreamWriter outfile = new StreamWriter(options.CloverOutput)) { outfile.Write(cloverreport.Execute(pe)); } } // Generate html report if (options.HtmlOutput != null) { HtmlReport htmlreport = new HtmlReport(); using (StreamWriter outfile = new StreamWriter(options.HtmlOutput)) { outfile.Write(htmlreport.Execute(pe)); } } }
private static int Main(string[] args) { Console.OutputEncoding = Encoding.UTF8; var commandLineApplication = new CommandLineApplication(); commandLineApplication.Name = "MiniCover"; commandLineApplication.Description = "MiniCover - Code coverage for .NET Core via assembly instrumentation"; commandLineApplication.Command("instrument", command => { command.Description = "Instrument assemblies"; var workDirOption = CreateWorkdirOption(command); var parentDirOption = CreateParentdirOption(command); var includeAssembliesOption = command.Option("--assemblies", "Pattern to include assemblies [default: **/*.dll]", CommandOptionType.MultipleValue); var excludeAssembliesOption = command.Option("--exclude-assemblies", "Pattern to exclude assemblies", CommandOptionType.MultipleValue); var includeSourceOption = command.Option("--sources", "Pattern to include source files [default: **/*]", CommandOptionType.MultipleValue); var excludeSourceOption = command.Option("--exclude-sources", "Pattern to exclude source files", CommandOptionType.MultipleValue); var hitsFileOption = command.Option("--hits-file", "Hits file name [default: coverage-hits.txt]", CommandOptionType.SingleValue); var coverageFileOption = CreateCoverageFileOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { var workdir = UpdateWorkingDirectory(workDirOption); var assemblies = GetFiles(includeAssembliesOption, excludeAssembliesOption, "**/*.dll", parentDirOption); if (assemblies.Length == 0) { throw new Exception("No assemblies found"); } var sourceFiles = GetFiles(includeSourceOption, excludeSourceOption, "**/*.cs", parentDirOption); if (sourceFiles.Length == 0) { throw new Exception("No source files found"); } var hitsFile = GetHitsFile(hitsFileOption); var coverageFile = GetCoverageFile(coverageFileOption); var instrumenter = new Instrumenter(assemblies, hitsFile, sourceFiles, workdir); var result = instrumenter.Execute(); SaveCoverageFile(coverageFile, result); return(0); }); }); commandLineApplication.Command("uninstrument", command => { command.Description = "Uninstrument assemblies"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var result = LoadCoverageFile(coverageFile); Uninstrumenter.Execute(result); return(0); }); }); commandLineApplication.Command("report", command => { command.Description = "Outputs coverage report"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var consoleReport = new ConsoleReport(); return(consoleReport.Execute(result, threshold)); }); }); commandLineApplication.Command("htmlreport", command => { command.Description = "Write html report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output folder for html report [default: coverage-html]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetHtmlReportOutput(outputOption); var htmlReport = new HtmlReport(output); return(htmlReport.Execute(result, threshold)); }); }); commandLineApplication.Command("xmlreport", command => { command.Description = "Write an NCover-formatted XML report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output file for NCover report [default: coverage.xml]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetXmlReportOutput(outputOption); XmlReport.Execute(result, output, threshold); return(0); }); }); new ResetCommand().AddTo(commandLineApplication); commandLineApplication.Command("opencoverreport", command => { command.Description = "Write an OpenCover-formatted XML report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output file for OpenCover report [default: opencovercoverage.xml]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetOpenCoverXmlReportOutput(outputOption); OpenCoverReport.Execute(result, output, threshold); return(0); }); }); commandLineApplication.Command("cloverreport", command => { command.Description = "Write an Clover-formatted XML report to folder"; var workDirOption = CreateWorkdirOption(command); var coverageFileOption = CreateCoverageFileOption(command); var thresholdOption = CreateThresholdOption(command); var outputOption = command.Option("--output", "Output file for Clover report [default: clover.xml]", CommandOptionType.SingleValue); command.HelpOption("-h | --help"); command.OnExecute(() => { UpdateWorkingDirectory(workDirOption); var coverageFile = GetCoverageFile(coverageFileOption); var threshold = GetThreshold(thresholdOption); var result = LoadCoverageFile(coverageFile); var output = GetCloverXmlReportOutput(outputOption); CloverReport.Execute(result, output, threshold); return(0); }); }); commandLineApplication.HelpOption("-h | --help"); commandLineApplication.OnExecute(() => { commandLineApplication.ShowHelp(); return(0); }); return(commandLineApplication.Execute(args)); }
protected override Task <int> Execute() { CloverReport.Execute(CoverageLoadedFileOption.GetValue(), CloverOutputOption.GetValue(), ThresholdOption.GetValue()); return(Task.FromResult(0)); }