NUnit3TestExecutor 抛出 ArgumentNullException - 值不能为空

NUnit3TestExecutor throwing an ArgumentNullException - Value cannot be null

我正在为我们的 CI/CD 管道使用 Azure DevOps。 Visual Studio 代理作业上的测试任务突然开始失败。

日志中的错误是:

An exception occurred while invoking executor 'executor://nunit3testexecutor/': Value cannot be null. (Parameter 'type')

任务定义如下:

steps:
- task: VSTest@2
  displayName: 'VsTest - testAssemblies'
  inputs:
    testAssemblyVer2: |
     **\*Tests.dll
     !**\*TestAdapter.dll
     !**\obj\**
     !**\bin\**\ref\**
    testFiltercriteria: 'FullyQualifiedName!~XXX.IntegrationTests'
    otherConsoleOptions: '/framework:".NETCoreApp,Version=v5.0"'

我查看了 NUnit3TestExecutor source code 但我看不到带有名为 'type'.

的参数的方法

我唯一可以使用此参数的地方是 System.Attribute (CoreCLR) class,NUnitAttribute 继承自:

public static Attribute[] GetCustomAttributes(MemberInfo element, Type type, bool inherit)
{
    ...

    if (type == null)
        throw new ArgumentNullException(nameof(type));
    ...
}

测试执行器突然开始失败是否有原因?

通过修改 Azure Pipeline 清理构建目录解决了这个问题。

转到:管道 > 获取源 > 清理选项

将其设置为值 'All build directories'。