在 Visual Studio Code 中,我有一个特定的单元测试,无论结果是什么 - 都标有问号。
我添加了其他测试,它们的行为符合预期(用绿色勾号或红色 x 标记)。
[Fact]
public async Task LinuxHelper_ExecuteInvalidCommandBash_ShouldFail()
{
//arrange
//act
//var bashExecutionResult = LinuxHelper.RunAsBash(@"dasda");
//assert
10.Should().Be(11);
//bashExecutionResult.Succeeded.Should().BeFalse();
//bashExecutionResult.Error.Should().NotBeNullOrEmpty();
//bashExecutionResult.ExitCode.Should().NotBe(0);
}
使用
C#
、.NET Core Test Explorer
VSC 扩展,以及 xUnit
和 FluentAssertions
。
对我来说,当我没有为 Dotnet-test-explorer.testProjectPath 设置设置全局模式,并且我的解决方案中有多个测试项目时,就会发生这种情况。一旦我将该选项设置为 **/*.Test.csproj,它就可以管理运行所有测试的结果。
我在 .NET Core Test Explorer(C#、xUnit)中遇到了同样的问题。仅当我使用 xUnit 的“DisplayName”参数时,才会出现此问题。
将
[Fact(DisplayName="Passing an invalid date throws an exception.")
更改为 [Fact]
解决了我的问题。