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.
We’re using NUnit as a test framework under the hood. Because of that all .feature files have auto-generated .cs files with NUnit tests.
public partial class LoginFeature
The easiest way to run it in Jenkins which I found is running it from the command line. In order to do that you need to use nunit-console.exe. The console can be downloaded from NUnit web site. The command line can look like:
"C:\Program Files (x86)\NUnit.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 Jenkins 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:
- To add a build step to your job ‘Execute Windows batch command’. Input the command to run the tests.
- To add a post build action ‘Publish NUnit test result report’ where you specify the path to the result XML from the command line.
In order to adjust browser settings you should login to the machine with the appropriate use and go to Internet Options (for IE).