Nunit 控制台运行程序可同时测试多个 dll

问题描述 投票:0回答:1

我有大约 20 个 dll 的列表,其中包含我想通过 Windows 计算机上的 Github 操作使用 nunit.consolerunner 运行的测试。使用 Powershell 我创建了一个包含所有 dll 的字符串并调用 nunit:

$testProjects = Get-ChildItem -Path ./Tests -Filter *Tests.dll -Recurse -Force
foreach ($project in $testProjects) {
  $projectPath = $project.FullName | Resolve-Path -Relative
  $projectList = $projectList + " """ + $projectPath + """"
}
$projectList = $projectList.Trim()
.\.nuget\nunit.consolerunner\*\tools\nunit3-console.exe --where "cat != AST" --result unittest-Results.xml --nocolor $projectList

但是我遇到了错误

System.IO.PathTooLongException : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

--PathTooLongException
The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
   at System.IO.PathHelper.GetFullPathName()
   at System.IO.Path.LegacyNormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at NUnit.Engine.TestPackage..ctor(String filePath)
   at NUnit.Engine.TestPackage..ctor(IList`1 testFiles)
   at NUnit.ConsoleRunner.ConsoleRunner.MakeTestPackage(ConsoleOptions options)
   at NUnit.ConsoleRunner.ConsoleRunner.Execute()
   at NUnit.ConsoleRunner.Program.Main(String[] args)

每个单独的 dll 路径都不会超过此限制。然而,所有路径的组合将超出限制。我已经在它周围添加了

"
,以确保并非所有路径都被解析为一个。

我是否向 Nunit 提供了错误的参数,或者是否存在测试文件的组合文件路径不能超过 260 个字符的限制?

如果存在这个限制,那么我在哪里制作一个 nunit 测试项目会起作用吗?

c# nunit nunit-console
1个回答
0
投票

只需更换:

$testProjects = Get-ChildItem -Path ./Tests -Filter *Tests.dll -Recurse -Force

与:

$testProjects = cmd /c dir /s/b .\Tests*.dll

© www.soinside.com 2019 - 2024. All rights reserved.