开发者

How should I group unit tests using C# and NUnit?

I've a class with a lot of unit tests in C# (using NUnit 2.5.8) and I'd like to group 开发者_如何学Cthe unit tests together based on which area of the class's functionality I'm testing (so I can quickly choose which set to run in the NUnit UI).

I know I could refactor the class into smaller components, which would solve the problem, but are there any other ways to do this without completely re-designing the production code?


Why not a [TestFixture] (separate class) for each area of functionality that you want to test?

class ClassThatDoesTooMuch {
    // functionality related to opening a database connection
    // functionality related to file management
    // functionality related to solving world hunger
}

[TestFixture]
public class ClassThatDoesTooMuchDatabaseConnectionTests { // }

[TestFixture]
public class ClassThatDoesTooMuchFileManagementTests { // }

[TestFixture]
public class ClassThatDoesTooMuchWorldHungerSolutionTests { // }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜