-
Notifications
You must be signed in to change notification settings - Fork 1
The TSR Module
This introduction will show you how to:
- add the NuGet package to Visual Studio
- create a PowerShell runner to trigger the execution in TeamCity
- configure TeamCity to show test results on the dashboard
- configure TeamCity to show the SpecFlow html report as part of the build
Let's begin!
- use NuGet
Install-Package TeamCity.SpecFlow.Reporting. (preferred way)
-
note: the package will add a PowerShell module (
TeamCity.SpecFlow.Reporting.psm1) to your project that does all the magic. (If you don't use NuGet, add the file manually to the root of the project) -
note 2: If your project uses .NET 4 or higher a config file,
specflow.exe.config, is also added and then copied to the location of specflow.exe during processing (and removed afterwards). This is because specflow.exe currently doesn't work for .NET 4>.

-
or manually download the PS module.
-
or install it globally via PSGet. Note that if you opt for this approach you will not use all the parts described in the next section (3).
OK, that's it...check-in|commit and be happy!
Now, let's go over to TeamCity.
- First make sure that a compilation build step (MSBuild runner) exist somewhere before your 'specflow build step' in the pipeline. Essentially, this means that you have to compile the VS project that contains the specflow features so that we can use the assembly it produces.
- Next, add a new build step (PowerShell runner, not an NUnit runner).

Change the working directory to where your SpecFlow VS project resides (where the .psm1 resides which is usually the root of that VS project).

- Execute the script...
You can choose to either have the code 'inline' inside TeamCity as source code (as shown below) or as a file that you include as part of source code. (an example of this approach is shown here)
# 1. Import the module
Import-Module .\TeamCity.SpecFlow.Reporting.psm1
# 2. Invoke the report generation
Invoke-TeamCitySpecFlowReport
And the result should be that a SpecFlow HTML report is added as an artifact to your build...and all of that was automatically.

Nice eh?!
- Test Details
In the previous step you might see that no details of tests passed was added to the dashboard page. That's easily added through a build feature where you pick the .xml report added by NUnit.

That's better plus this gives us the benefit of not having tests that fail not being reported as a failed build.

- The Report Tab
Finally, let's add the report tab showing that "beautiful" report generated by SpecFlow. From the administration view create a new report tab, then "add" the .html file that's was put as an artifact to the build just now and TeamCity will display the tab if it can find the artifact you just picked. (you can read more about this right here)

...and there we go, ain't that pretty!!

Next - [the defaults]