Skip to content

Commit

Permalink
merge reporting to specflow.exe, and small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gasparnagy committed Nov 25, 2009
1 parent 2bef638 commit 13da34f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 33 deletions.
11 changes: 9 additions & 2 deletions Reporting/NUnitExecutionReport/NUnitExecutionReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 6 additions & 20 deletions Reporting/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
/*using System;
using System.Collections.Generic;
using System.IO;
using NConsoler;
Expand All @@ -24,19 +24,9 @@ public static void StepDefinitionReport(
[Optional("StepDefinitionReport.html", "out")] string outputFile
)
{
SpecFlowProject specFlowProject = MsBuildProjectReader.LoadSpecFlowProjectFromMsBuild(projectFile);

List<Feature> parsedFeatures = ParserHelper.GetParsedFeatures(specFlowProject);

var basePath = Path.Combine(specFlowProject.ProjectFolder, binFolder);
List<BindingInfo> 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]
Expand All @@ -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));
}
}
}
}*/
14 changes: 13 additions & 1 deletion Reporting/StepDefinitionReport/StepDefinitionReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace TechTalk.SpecFlow.Reporting.StepDefinitionReport
{
internal class StepDefinitionReportGenerator
public class StepDefinitionReportGenerator
{
private readonly SpecFlowProject specFlowProject;
private readonly List<BindingInfo> bindings;
Expand All @@ -27,6 +27,18 @@ internal class StepDefinitionReportGenerator
private Dictionary<StepDefinition, BindingInfo> bindingByStepDef;
private readonly List<StepDefinition> stepDefsWithNoBinding = new List<StepDefinition>();

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<BindingInfo> bindings, List<Feature> parsedFeatures, bool showBindingsWithoutInsance)
{
this.specFlowProject = specFlowProject;
Expand Down
7 changes: 3 additions & 4 deletions Reporting/TechTalk.SpecFlow.Reporting.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{FC43509F-E7D3-40C4-B4C3-1E6C9D5530A4}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TechTalk.SpecFlow.Reporting</RootNamespace>
<AssemblyName>TechTalk.SpecFlow.Reporting</AssemblyName>
Expand All @@ -22,6 +22,8 @@
</SccProvider>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\specflow.snk</AssemblyOriginatorKeyFile>
<StartupObject>
</StartupObject>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand Down Expand Up @@ -56,9 +58,6 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\lib\nconsoler\NConsoler.cs">
<Link>NConsoler\NConsoler.cs</Link>
</Compile>
<Compile Include="..\VersionInfo.cs">
<Link>VersionInfo.cs</Link>
</Compile>
Expand Down
39 changes: 34 additions & 5 deletions Tools/Program.cs
Original file line number Diff line number Diff line change
@@ -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
{
Expand All @@ -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
Expand All @@ -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
}
}
4 changes: 4 additions & 0 deletions Tools/TechTalk.SpecFlow.Tools.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@
<Project>{7CCEF6D6-FC17-422E-9BED-EDD752B6496F}</Project>
<Name>TechTalk.SpecFlow.Parser</Name>
</ProjectReference>
<ProjectReference Include="..\Reporting\TechTalk.SpecFlow.Reporting.csproj">
<Project>{FC43509F-E7D3-40C4-B4C3-1E6C9D5530A4}</Project>
<Name>TechTalk.SpecFlow.Reporting</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="MsBuild\TechTalk.SpecFlow.targets">
Expand Down
2 changes: 1 addition & 1 deletion lib/nconsoler/NConsoler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down

0 comments on commit 13da34f

Please sign in to comment.