How To: Running Specflow features with Selenium in Jenkins

This is a short guide how to run Specflow features which use Selenium for interaction with a web site. In our building environment these tests are running in Jenkins. Implementing this you’ll get automated UI-test runner.

Running Tests

We’re using as a test framework under the hood. Because of that all .feature files have auto-generated .cs files with tests.

[System.CodeDom.Compiler.GeneratedCodeAttribute("TechTalk.SpecFlow", "")]
public partial class LoginFeature
// skipped

The easiest way to run it in which I found is running it from the command line. In order to do that you need to use -console.exe. The console can be downloaded from NUnit web site.  The command line can look like:

"C:\Program Files (x86)\.Org\bin\nunit-console.exe" D:\..\Project\bin\Debug\Project.dll --trace=Verbose --result=D:\..\Project\bin\Debug\TestResult.xml;format=nunit2

More abut command line parameters here.


In the command line above the key “format=nunit2” is important for because the new format of result XML is not supported. We’re using Jenkins ver. 1.647. Without it the results won’t be imported. In order to run tests you should do the following:

  1. To add a build step to your job ‘Execute Windows batch command’. Input the command to run the tests.
  2. To add a post build action ‘Publish NUnit test result report’ where you specify the path to the result XML from the command line.
  3. Make sure settings for browsers allows and other required features. It should be done for each web driver that you use.

In order to adjust browser settings you should login to the machine with the appropriate use and go to Internet Options (for IE).

Configuring the Project

The project with Specflow features that use Selenium also must be adopted. In order to do that I just added several suggested official packages: RC, WebDriver, WebDriverBackedSelenium, Support.

See Also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Related Post

%d bloggers like this: