xUnit global setup / teardown [migrated]
- by Codism
I need to run some code before any test is executed and also some code after all tests are done. I thought there must be some attributes or marker interface to indicate the global initialization and termination code but couldn't find them.
Alternatively, if I can invoke xUnit programmatically, I can also achieve what I want to do by the following code:
... Main(string[] args) {
try {
MyGlobalSetup();
RunAllTests(); // What goes into this method?
}
finally {
MyGlobalTeardown();
}
}
Can anyone provide me some hint about how to declaratively or programmally run some global setup/teardown code?
Thanks