asp.net mvc - What is the NUnit framework lifecycle execution order? -
recently, added test project in asp.net mvc project based on nunit framework (version 3.7.1.0). know there attributes in nunit other frameworks can add them our class , methods in order write better tests cases.
here attributes introduced nunit documentation:
- setup
- teardown
- testfixturesetup
- testfixtureteardown
i'd know execution order , performance consideration behind scenes implementing that.
i'd know execution order
setup/teardown methods related testfixture
executed once testfixture. setup/teardown methods related test
executed for each test. here order loop in middle:
testfixturesetup // executed once before first test setup setup // excuted before *each* test teardown // executed after *each* test testfixtureteardown // executed once after last test teardown
i use setup
method move there code repeated in arrange part of test. intialize sut in setup
method creating , providing required mocked dependencies.
testfixturesetup
more global - prepares battleground tests in fixture. usually, use initialize environment - e.g. create database and/or setup tables initial data. testfixtureteardown
used drop database. of course, environment initialization not related unit tests - it's acceptance tests.
performance consideration behind scenes implementing that
same other method calls. depends on put setup or teardown methods.
Comments
Post a Comment