SpecFlow Integration in TeamCity

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

SpecFlow – TeamCity Integration

I - Automate SpecFlow tests with SpecFlow + Runner (aka SpecRun)


(Cancelled)
Steps:

On TeamCity, open project's build steps configuration

Click on Add build step

Choose Command Line.

Configure the build step as follows:

- Run: executable with parameters.


- Command executable: enter the path to SpecRun.exe.
- Command parameters: enter the command line parameters for SpecRun.exe. Use the
BuildServerRun option and include /buildserver:teamcity.
o Information on executing command lines in TeamCity is available here. More details on
the SpecFlow+ Runner's command line options can be found here.

https://specflow.org/plus/documentation/SpecFlowPlus-and-TeamCity/

Pros:

- Advanced test runner features: execution profiles, target environment, attach artifacts to test
execution reports, TeamCity integration, complex scenarios filter expressions.
- Allow parallel test execution: by defining multiple threads, how often the tests are retried, and
when to abort a test run.
- Dedicated support for integration test execution: allow config file transfomation and
deployment steps, rerun tests for different environments and configurations, detect flickering
scenarios.
- Advanced test execution scheduling: run previously failing tests first, retry scenarios, execution
history available as OData.
- Customizable HTML reports using Razor templates.

Cons

- Project cancelled as of 11/2022.


- No support for C# 6.0.

II - Automate SpecFlow tests with SpecFlow + LivingDoc


Steps:

- On the local, Selenium-SpecFlow sanity test project, export Selenium test cases as NUnit:
o Add a new project for Selenium Tests.

o Add Nuget packages, install NUnit and Selenium Remote Control.


o Create a folder in which to place the unit tests.
o Convert selenium tesst cases: File -> Batch convert test cases ->
C#/NUnit/RemoteControl.
o Select the tests folder created in step 3 as the destination folder.
o Select all test cases and they should be saved as C# files in the Tests folder.
- On local project, install SpecFlow NuGet packages, including SpecFlow.Plus.LivingDoc.
- Create a new project on TeamCity for the Selenium-SpecFlow sanity test project.
- Configure the project's build trigger to run:
o On self-finish build: we are not using this because this is overwhelming for sanity
testing.
o On Patch Tuesday finish build.
o On schedule.
- Configure a new build step to run test cases from the SpecFlow sanity test project: command
line to run SpecFlow tests.
- If using LivingDoc, configure another step to generating document. (LivingDoc enables sharing
the test cases and results to every team member of all roles)
o Install on the build agent: dotnet tool install --global SpecFlow.Plus.LivingDoc.CLI
o After installing the LivingDoc CLI tool, the next step is to invoke it after each build and
each test run:
 livingdoc test-assembly "$TestAssemblyPath" --binding-assemblies
"$TestAssemblyPath" --output-type HTML --output "$LivingDocDir\
PLAppLivingDoc.html"
o For generating LivingDoc after test runs, use PowerShell command:
 livingdoc test-assembly "$TestAssemblyPath" --test-execution-json
"$TestExecutionPath" --output-type HTML --output "$HtmlReportPath" --title
"PL App Boa Tests"
- Configure notifications to send build results to individuals.

You might also like