[英]What's a good way to write Unit tests for code with protected objects C# (using NMock, and NUnit framework)
[英]How should I group unit tests using C# and NUnit?
我有一個在C#中使用大量單元測試的類(使用NUnit 2.5.8),我想根據我正在測試的類功能區域將單元測試組合在一起(所以我可以快速選擇哪個設置為在NUnit UI中運行)。
我知道我可以將類重構為更小的組件,這可以解決問題,但是有沒有其他方法可以做到這一點而無需完全重新設計生產代碼?
為什么不對要測試的每個功能區域使用[TestFixture]
(單獨的類)?
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 { // }
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.