我的項目在規模和功能上都在不斷增長,所以我決定使用NUnit測試一些功能,但是我面臨的問題是大多數方法都是靜態的,所以對我產生的第一件事是創建公共方法,我從單元測試類調用它們,但是這些公共方法開始很多,所以我想知道是不是在主類中創建新的Public方法,我應該創建一個接口,或者如果靜態方法應該是Public使用類中間實例化。NUnit - Static Vs.公共方法
這是我的程序是如何構成的一個例子,
namespace Mynamespace
{
public class Foo
{
InsertUser();
SortUser();
}
static void InsertUser()
{
}
static void SortUser()
{
}
//Here start the public methods to be called from the unit test class
public DoSort()
{
InsertUser();
SortUser();
}
}
什麼是保持彼此分離,我的程序和測試類的主要邏輯,最好的辦法?
感謝,
我將所有方法從靜態移動到實例。感謝您提供有關抽象而不是實現的建議。 – m0dest0