c# - Is it possible to execute a method before and after all tests in the assembly? -
i built nunit project selenium ui automation. sign in site before running tests (all of them) , close browser after running tests (all of them).
i can't use setup since related fixtures , want before , after everything.
do know execute it?
i'm familiar setup , teardown attribute. let me explain again.
i need logic executed before tests fixtures starts (aka - first test in entire assembly) , logic executed after tests fixtures ended (aka - last test in entire assembly).
if test fixtures within same namespace can use [setupfixture]
attribute mark class global setup , teardown. can put login/logout functionality in there.
nunit 2.x
namespace mynamespace.tests { using system; using nunit.framework; [setupfixture] public class testssetupclass { [setup] globalsetup() { // login here. } [teardown] globalteardown() { // logout here } } }
see: http://www.nunit.org/index.php?p=setupfixture&r=2.4
nunit 3.x
namespace mynamespace.tests { using system; using nunit.framework; [setupfixture] public class testssetupclass { [onetimesetup] globalsetup() { // login here. } [onetimeteardown] globalteardown() { // logout here } } }
see: https://github.com/nunit/docs/wiki/setupfixture-attribute
Comments
Post a Comment