0
我有一個Nunit TestFixtureData測試夾具。
在visual studio測試資源管理器中,測試被標記爲「未運行測試」。我想讓他們工作。我想讓他們作爲紅色/綠色測試運行。Nunit TestFixtureData未運行測試
我有Foo Factory throw沒有執行expirs這些測試運行,並顯示不工作。
我有其他TestFixtureData具有測試和TestCase,他們工作正常。
我不想讓邏輯通過測試,我知道應該是什麼。
在測試資源管理器上,我可以剖析測試,並得到「路徑中存在非法字符」。在輸出中。不確定這是否相關。
/// <summary>
/// This is a TestFixtureData test. See https://github.com/nunit/docs/wiki/TestFixtureData for more information
/// </summary>
[TestFixtureSource(typeof(FooTest), "FixtureParms")]
public class FooTestFixture
{
private readonly Foo foo;
private readonly Guid fooId;
public FooTestFixture(Foo foo, Guid fooId)
{
this.foo = foo;
this.fooId = fooId;
}
[Test]
public void FooId_IsSet()
{
//Arrange
//Act
var value = foo.FooId;
//Assert
Assert.AreNotEqual(Guid.Empty, value);
}
[TestCase("A")]
[TestCase("B")]
[TestCase("C")]
public void ActivityList_Contains(string activity)
{
//Arrange
//Act
var value = foo.ActivityList;
//Assert
Assert.IsTrue(value.Contains(activity));
}
}
public class FooTest
{
public static IEnumerable FixtureParms
{
get
{
var fooId = Guid.NewGuid();
var foo = new Foo() { FooId = fooId };
yield return new TestFixtureData(FooFactory.Edit(foo), fooId);
yield return new TestFixtureData(FooFactory.Create(fooId), fooId);
yield return new TestFixtureData(foo, fooId);
}
}
}
與FooFactory一起幹活。我知道這會通過測試但測試沒有運行
public static Foo Create(Guid fooId)
{
return new Foo();
}
public static Foo Edit Edit(Foo foo)
{
return new Foo();
}
您的代碼對我來說沒有意義。 FooTestFixture的構造函數接受一個Foo和一個guid,但是你在TestFixtureAttribute中傳入一個Type和一個字符串。 NUnit會簡單地決定它根本不能使用這個類,並將其標記爲無效。由於測試瀏覽器不報告有關類的任何信息(僅限於方法),因此在其下運行時,錯誤可能會消失。使用NUnit控制檯運行程序運行可能會告訴您該燈具無效。 – Charlie