Install Nunit TimeoutAttribute from SpecFlow

I wrote some lengthy end-to-end integration tests using SpecFlow, but they do not work due to Nunit timeouts.

Adding the [Timeout (x)] attribute to TestFixture solves the problem, but, of course, is overwritten every time the function is updated.

How can I remove or extend the timeout in a way that SpecFlow will respect?

+4
source share
3 answers

According to @DisscCoder, Add the tag category to the script in the function file and add a hook to it that corresponds to the hooks class .... SpecFlow runs the code hook code before the script for all scripts where the string corresponds.

namespace ClassLibrary1 { [Binding] public class Hooks1 { [BeforeScenario("LongTest")] public void BeforeScenario() { // Code to set Nunit timeout } } } 

Cucumber:

 @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... 
+2
source

I only understand that I understood Specflow, but can you implement a custom tag that could do this? Maybe you can place them on BeforeScenario or BeforeFeature hooks?

+1
source

How long have we been talking? > 1 minute? Should there be a full integration test?

I read a book of cucumber - she suggested that you cheat as much as possible for your GIVEN steps, in order to reduce the time required to start something. ACTIVE steps describe the past.

I have an application form, which consists of 5 sections and can be submitted only after completion of all sections. I wanted to test some functions that occur when submitting the application, initially my GIVEN statements controlled the web page through Selenium to fill in all 5 sections of the form so that I could submit, I changed this to one SQL command to set the application status for all sections. It chopped a minute.

What I tested was submission behavior, filling out section tests is done elsewhere.

+1
source

Source: https://habr.com/ru/post/1398022/


All Articles