It turns out that this functionality exists in NUnit, it's just not very obvious or intuitive.
According to Charlie Poole in the function request I made for this function here , he claims that the following will work, which is a direct quote from him.
Decorate the class outside of any namespace with [SetUpFixture]. Decorate the method of this class with [TearDown]. If you want, decorate another with [SetUp].
Differences from what you ask for:
The name makes this a bit unobvious in this use.
NUnit allows any number of them and calls them all, without any guarantee of order. This is by design.
It can be applied to a static or instance. If this is an instance method, the class must have a default constructor, and it will be created with the duration of the entire test run. It is also a design.
Now itβs not very, but it should achieve the same functionality, and maybe it will make it a little cleaner in 3.0. :)
source share