I'm planning on implementing some tests using nUnit. I also have a homegrown metrics recording library that I'd like to use to use to get some metrics out of the test. Said metrics library is normally used in applications, and is usually used something like this:
// retrieve configuration.
string path = GetPath();
bool option = GetOption();
// Set up metrics recording object.
Metrics m = new Metrics(path, option);
Do.Something();
m.AddRecord(new Record()); // Record some metrics on what just happened
// later...
m.Finish(); // let it know we're done.
Now, I could create an instance of this object using TestFixtureSetup
and TestFixtureTeardown
in each object (such as in a parent test class), but I'd much rather have this metrics object persist across all tests run. Is it possible, and if so, what's necessary to do that?