我使用此处描述的 PriorityOrderer : https://learn.microsoft.com/en-us/dotnet/core/testing/order-unit-tests?pivots=xunit
它工作正常,但如果测试失败我想打破。
看起来像这样的东西:
foreach (TTestCase testCase in
sortedMethods.Keys.SelectMany(
priority => sortedMethods[priority].OrderBy(
testCase => testCase.TestMethod.Method.Name)))
{
yield return testCase;
if (HasFailed(testCase))
{
yield break;
}
}
但是我找不到如何实现我的
hasFailed
功能
stopOnFail
设置?
将此设置为
可在测试失败后停止运行进一步的测试。true
xunit.runner.json
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json",
"stopOnFail": true
}
.csproj
<ItemGroup>
<Content Include="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>