![](/img/trans.png)
[英]“Inconclusive: Test not run” error running unit tests in debug mode in Visual Studio / Resharper
[英]ReSharper unit test runner gives Inconclusive to the outer class
我有使用nUnit編寫的單元測試,測試結構與Phil Haack的帖子類似
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&Wayne是正確的,外部類只用於分組,因此從類更改為命名空間是最佳解決方案。
您的外部類僅對相關方法進行分組,建議將其替換為命名空間。
namespace MyNamespace.ClassToTest
{
...
}
你可能有一個沒有[Test]的[TestFixture] - 也許外層沒有任何自己的測試? 在哪種情況下,為什么不使用命名空間?
只是一個猜測,類上的屬性會導致您的類被作為一個測試類處理,但是在類中沒有測試它會導致我們的不確定:
[TestFixture]
public class ClassToTest
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.