xUnit.net框架中是否有类似于NUnit的以下功能的方法?
[Test, TestCaseSource("CurrencySamples")]
public void Format_Currency(decimal value, string expected){}
static object[][] CurrencySamples = new object[][]
{
new object[]{ 0m, "0,00"},
new object[]{ 0.0004m, "0,00"},
new object[]{ 5m, "5,00"},
new object[]{ 5.1m, "5,10"},
new object[]{ 5.12m, "5,12"},
new object[]{ 5.1234m, "5,12"},
new object[]{ 5.1250m, "5,13"}, // round
new object[]{ 5.1299m, "5,13"}, // round
}
这将在NUnit GUI中生成8个单独的测试
[TestCase((string)null, Result = "1")]
[TestCase("", Result = "1")]
[TestCase(" ", Result = "1")]
[TestCase("1", Result = "2")]
[TestCase(" 1 ", Result = "2")]
public string IncrementDocNumber(string lastNum) { return "some"; }
这将生成5个单独的测试,并自动比较结果(Assert.Equal()
)。
[Test]
public void StateTest(
[Values(1, 10)]
int input,
[Values(State.Initial, State.Rejected, State.Stopped)]
DocumentType docType
){}
这将生成6个组合测试。无价。
几年前,我尝试并喜欢xUnit,但它缺少这些功能。没有他们就无法生存。有什么改变吗?