I've written several long running end to end integration tests using SpecFlow, but they are failing due to Nunit timeouts.
Adding the [Timeout(x)] attribute to the TestFixture solves the issue, but of course gets overwritten everytime the feature is updated.
How can I remove or extend the timeout in a way that SpecFlow will respect?
I am only getting to understand Specflow but could you implement a custom tag that could do this? Maybe you could place these at the BeforeScenario or BeforeFeature hooks?
How long running are we talking about? > 1 minute?
Does it have to be a full integration test?
I was reading the cucumber book - it suggested that you cheat as much as possible for your GIVEN steps to reduce the time it takes for things to run. GIVEN steps are describing the past.
I have an application form that has 5 sections to complete and can only be submitted once all sections are completed. I wanted to test some functionality that occurs on submission of the application, originally my GIVEN statements were driving the webpage through Selenium to complete all 5 sections of the form so that I could submit, I changed this to a single SQL command to set the app status for all the sections to completed. This chopped about a minute off the runtime.
The thing I was testing was the submission behaviour, the filling out the sections tests are done elsewhere.
As @DisscCoder says,
Add a tag category to the scenario in the feature file, and add a hook that matches in a hooks class....
SpecFlow runs the before scenario code hook code for all scenarios where the string matches.
namespace ClassLibrary1
{
[Binding]
public class Hooks1
{
[BeforeScenario("LongTest")]
public void BeforeScenario()
{
// Code to set Nunit timeout
}
}
}
Gherkin:
@LongTest
Scenario: Calc Pi to 1m digits (long)
Given I am computing PI
And my precision is 1 million digits
Then my result is 3.14...