From 13da34f0767a41a732cdf964c8c6f73732ba6722 Mon Sep 17 00:00:00 2001 From: Gaspar Nagy Date: Wed, 25 Nov 2009 11:16:48 +0100 Subject: [PATCH] =?UTF-8?q?=EF=BB=BFmerge=20reporting=20to=20specflow.exe,?= =?UTF-8?q?=20and=20small=20fixes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NUnitExecutionReportGenerator.cs | 11 +++++- Reporting/Program.cs | 26 +++---------- .../StepDefinitionReportGenerator.cs | 14 ++++++- Reporting/TechTalk.SpecFlow.Reporting.csproj | 7 ++-- Tools/Program.cs | 39 ++++++++++++++++--- Tools/TechTalk.SpecFlow.Tools.csproj | 4 ++ lib/nconsoler/NConsoler.cs | 2 +- 7 files changed, 70 insertions(+), 33 deletions(-) diff --git a/Reporting/NUnitExecutionReport/NUnitExecutionReportGenerator.cs b/Reporting/NUnitExecutionReport/NUnitExecutionReportGenerator.cs index 1d93ea452..79038052e 100644 --- a/Reporting/NUnitExecutionReport/NUnitExecutionReportGenerator.cs +++ b/Reporting/NUnitExecutionReport/NUnitExecutionReportGenerator.cs @@ -11,13 +11,20 @@ namespace TechTalk.SpecFlow.Reporting.NUnitExecutionReport { - internal class NUnitExecutionReportGenerator + public class NUnitExecutionReportGenerator { private ReportElements.NUnitExecutionReport report; - private SpecFlowProject specFlowProject; + private readonly SpecFlowProject specFlowProject; private readonly string xmlTestResultPath; private readonly string labeledTestOutputPath; + public NUnitExecutionReportGenerator(string projectFile, string xmlTestResultPath, string labeledTestOutputPath) + { + this.xmlTestResultPath = xmlTestResultPath; + this.specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile); + this.labeledTestOutputPath = labeledTestOutputPath; + } + public NUnitExecutionReportGenerator(SpecFlowProject specFlowProject, string xmlTestResultPath, string labeledTestOutputPath) { this.xmlTestResultPath = xmlTestResultPath; diff --git a/Reporting/Program.cs b/Reporting/Program.cs index ef1e23c59..bdb466df6 100644 --- a/Reporting/Program.cs +++ b/Reporting/Program.cs @@ -1,4 +1,4 @@ -using System; +/*using System; using System.Collections.Generic; using System.IO; using NConsoler; @@ -24,19 +24,9 @@ public static void StepDefinitionReport( [Optional("StepDefinitionReport.html", "out")] string outputFile ) { - SpecFlowProject specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile); - - List parsedFeatures = ParserHelper.GetParsedFeatures(specFlowProject); - - var basePath = Path.Combine(specFlowProject.ProjectFolder, binFolder); - List bindings = BindingCollector.CollectBindings(specFlowProject, basePath); - - StepDefinitionReportGenerator generator = new StepDefinitionReportGenerator(specFlowProject, bindings, parsedFeatures, - true); + StepDefinitionReportGenerator generator = new StepDefinitionReportGenerator(projectFile, binFolder, true); generator.GenerateReport(); - - string outputFilePath = Path.GetFullPath(outputFile); - generator.TransformReport(outputFilePath); + generator.TransformReport(Path.GetFullPath(outputFile)); } [Action] @@ -47,16 +37,12 @@ public static void NUnitExecutionReport( [Optional("TestResult.html", "out")] string outputFile ) { - SpecFlowProject specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile); - NUnitExecutionReportGenerator generator = new NUnitExecutionReportGenerator( - specFlowProject, + projectFile, Path.GetFullPath(xmlTestResult), Path.GetFullPath(labeledTestOutput)); generator.GenerateReport(); - - string outputFilePath = Path.GetFullPath(outputFile); - generator.TransformReport(outputFilePath); + generator.TransformReport(Path.GetFullPath(outputFile)); } } -} \ No newline at end of file +}*/ \ No newline at end of file diff --git a/Reporting/StepDefinitionReport/StepDefinitionReportGenerator.cs b/Reporting/StepDefinitionReport/StepDefinitionReportGenerator.cs index 6fda176d7..c4718e521 100644 --- a/Reporting/StepDefinitionReport/StepDefinitionReportGenerator.cs +++ b/Reporting/StepDefinitionReport/StepDefinitionReportGenerator.cs @@ -15,7 +15,7 @@ namespace TechTalk.SpecFlow.Reporting.StepDefinitionReport { - internal class StepDefinitionReportGenerator + public class StepDefinitionReportGenerator { private readonly SpecFlowProject specFlowProject; private readonly List bindings; @@ -27,6 +27,18 @@ internal class StepDefinitionReportGenerator private Dictionary bindingByStepDef; private readonly List stepDefsWithNoBinding = new List(); + public StepDefinitionReportGenerator(string projectFile, string binFolder, bool showBindingsWithoutInsance) + { + specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile); + + parsedFeatures = ParserHelper.GetParsedFeatures(specFlowProject); + + var basePath = Path.Combine(specFlowProject.ProjectFolder, binFolder); + bindings = BindingCollector.CollectBindings(specFlowProject, basePath); + + this.showBindingsWithoutInsance = showBindingsWithoutInsance; + } + public StepDefinitionReportGenerator(SpecFlowProject specFlowProject, List bindings, List parsedFeatures, bool showBindingsWithoutInsance) { this.specFlowProject = specFlowProject; diff --git a/Reporting/TechTalk.SpecFlow.Reporting.csproj b/Reporting/TechTalk.SpecFlow.Reporting.csproj index 83a26445f..2ece5eeaa 100644 --- a/Reporting/TechTalk.SpecFlow.Reporting.csproj +++ b/Reporting/TechTalk.SpecFlow.Reporting.csproj @@ -6,7 +6,7 @@ 9.0.30729 2.0 {FC43509F-E7D3-40C4-B4C3-1E6C9D5530A4} - Exe + Library Properties TechTalk.SpecFlow.Reporting TechTalk.SpecFlow.Reporting @@ -22,6 +22,8 @@ true ..\specflow.snk + + true @@ -56,9 +58,6 @@ - - NConsoler\NConsoler.cs - VersionInfo.cs diff --git a/Tools/Program.cs b/Tools/Program.cs index 82ac5ba3c..f7f98fe0d 100644 --- a/Tools/Program.cs +++ b/Tools/Program.cs @@ -1,7 +1,10 @@ using System; +using System.IO; using NConsoler; using TechTalk.SpecFlow.Generator; using TechTalk.SpecFlow.Generator.Configuration; +using TechTalk.SpecFlow.Reporting.NUnitExecutionReport; +using TechTalk.SpecFlow.Reporting.StepDefinitionReport; namespace TechTalk.SpecFlow.Tools { @@ -13,8 +16,8 @@ static void Main(string[] args) return; } - [Action("Generate tests from all feature files")] - public static void Generate( + [Action("Generate tests from all feature files in a project")] + public static void GenerateAll( [Required] string projectFile, [Optional(false, "force", "f")] bool forceGeneration, [Optional(false, "verbose", "v")] bool verboseOutput @@ -26,10 +29,36 @@ public static void Generate( batchGenerator.ProcessProject(specFlowProject, forceGeneration); } - [Action] - public static void ToBeDefinedAction() + #region Reports + + [Action("Generates a report about usage and binding of steps")] + public static void StepDefinitionReport( + [Required] string projectFile, + [Optional("bin\\Debug")] string binFolder, + [Optional("StepDefinitionReport.html", "out")] string outputFile + ) { - + StepDefinitionReportGenerator generator = new StepDefinitionReportGenerator(projectFile, binFolder, true); + generator.GenerateReport(); + generator.TransformReport(Path.GetFullPath(outputFile)); } + + [Action("Formats an NUnit execution report to SpecFlow style")] + public static void NUnitExecutionReport( + [Required] string projectFile, + [Optional("TestResult.xml")] string xmlTestResult, + [Optional("TestResult.txt", "testOutput")] string labeledTestOutput, + [Optional("TestResult.html", "out")] string outputFile + ) + { + NUnitExecutionReportGenerator generator = new NUnitExecutionReportGenerator( + projectFile, + Path.GetFullPath(xmlTestResult), + Path.GetFullPath(labeledTestOutput)); + generator.GenerateReport(); + generator.TransformReport(Path.GetFullPath(outputFile)); + } + + #endregion } } \ No newline at end of file diff --git a/Tools/TechTalk.SpecFlow.Tools.csproj b/Tools/TechTalk.SpecFlow.Tools.csproj index 10de94e81..308579ce3 100644 --- a/Tools/TechTalk.SpecFlow.Tools.csproj +++ b/Tools/TechTalk.SpecFlow.Tools.csproj @@ -69,6 +69,10 @@ {7CCEF6D6-FC17-422E-9BED-EDD752B6496F} TechTalk.SpecFlow.Parser + + {FC43509F-E7D3-40C4-B4C3-1E6C9D5530A4} + TechTalk.SpecFlow.Reporting + diff --git a/lib/nconsoler/NConsoler.cs b/lib/nconsoler/NConsoler.cs index 375a5b581..591e37caa 100644 --- a/lib/nconsoler/NConsoler.cs +++ b/lib/nconsoler/NConsoler.cs @@ -507,7 +507,7 @@ private void PrintGeneralMulticommandUsage() _messenger.Write("Available subcommands:"); foreach (MethodInfo method in _actionMethods) { - _messenger.Write(method.Name.ToLower() + " " + GetMethodDescription(method)); + _messenger.Write(method.Name.ToLower() + " - " + GetMethodDescription(method)); } }