unit testing - Specflow BeforeScenario been called four times -


i have solution contains set of tests can run using nuints. trying integrate specflow it:

[testfixture] [binding] public class testbase {     protected iwindsorcontainer container {get; set; }     protected imongocollectionmanager collectionmanager { get; set; }     protected idatabasemanager databasemanager { get; set; }      [testfixturesetup]     [beforescenario,clscompliant(false)]     public void setup()     {         container = testfixture.container;         collectionmanager = container.resolve<imongocollectionmanager>();         databasemanager = container.resolve<idatabasemanager>();     }      [testfixtureteardown]     public void teardown()     {         container.release(collectionmanager);         container.release(databasemanager);      }  } 

everytime run feature file has 1 scenario executes before tests 4 times, before goes given of scenario when run using simple nuint works correctly , gets called once. can 1 me figure out why please? thanks, bijo

since automatically wired specflow, shouldn't need these nunit attributes in step class:

[testfixture] [testfixturesetup] [testfixtureteardown] 

i not sure how many scenarios have in feature, beforescenario run before each scenario. if want code run once before or after feature can use these hooks:

[beforefeature] [afterfeature] 

if want code run once before or after each scenario in feature can use these hooks:

[beforescenario] [afterscenario] 

also, if need clscompliant(false) on method, should add own attribute:

[clscompliant(false)] 

you can check out specflow docs more information on specflow hook attributes on https://github.com/techtalk/specflow/wiki/hooks.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -