我正在计划使用nUnit实施一些测试。我还有一个本地的度量记录库,我想用它来从测试中获取一些指标。所述度量库在应用中通常使用的,并且通常使用这样的事:如何在NUnit测试对象之间使用持久对象?
// 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.
现在,我可以在每个对象使用TestFixtureSetup
和TestFixtureTeardown
创建该对象的一个实例(例如,在父测试类) ,但我宁愿让这个度量对象持续在全部测试运行。是否有可能,如果有的话,有什么必要这样做?
看起来像这是nUnit的方式。谢谢! – 2009-09-22 00:18:12
不错,我不知道这个属性... – 2009-09-22 00:24:10