我一直在使用NUnit的單元測試,筆試和測試結構以類似的方式在Phil Haack's postReSharper的單元測試亞軍給人尚無定論外部類
namespace MyNamespace
{
[TestFixture]
public class ClassToTest
{
[TestFixture]
public class MethodToTest
{
[Test]
public void ThrowsArgumentNullException_OnNullIndex()
{
...
}
.. more tests for the method ..
}
[TestFixture]
public class AnotherMethodToTest
{
[Test]
public void ThrowsArgumentNullException_OnNullIndex()
{
...
}
.. more tests for the method ..
}
}
}
我的問題是,我得到定論的外用於對單元測試進行分組的類。我已經嘗試過在外部和/或內部階層有[TestFixture]
,但它總是給我不確定的。
我認爲正確的行爲應該是顯示來自內部類測試的單元測試狀態。有任何想法嗎?
更新
一個醜陋修復似乎是創建一個虛擬測試外部類,然後把屬性Ignore
就可以了。
[Test, Ignore]
public void DummyTest()
{
Assert.IsTrue(true);
}
更新2
Channs &韋恩是正確的,外類只是用於分組,從類,以便更改爲命名空間是最好的解決方案。
我最近有一個類似的東西,這只是因爲我創建了一個空測試。你有沒有得到任何空的測試? – 2012-08-01 13:27:57