我有一个 .dll 文件列表。如何在 NUnit 中运行它们?
我记得Python文件可以这样运行
suite = unittest.TestLoader().discover("./","*.py")
runner = unittest.TestRunner()
runner.run(suite)
现在我有一个 .dll 文件列表。有没有办法像 NUnit 中的 Python 一样运行它们?
是的,您可以使用
NUnit
做到这一点。使用 NuGet 或通过 NUnit 网站安装 NUnit Console Runner
:
nuget install NUnit.Console
安装
NUnit Console
后,运行此脚本:
nunit3-console.exe YourTestAssembly1.dll YourTestAssembly2.dll
此命令告诉
NUnit Console Runner
从列出的程序集中运行测试。如果您有多个 DLL,请将它们全部列出并用空格分隔。
如何:运行目录中的所有 DLL 您需要编写一些 Powershell 脚本。您也可以使用其他脚本语言。
Powershell 示例:
$dlls = Get-ChildItem -Path . -Filter *.dll
$dllList = $dlls -join " "
& "path_to_nunit3-console.exe" $dllList
有关
NUnit Console Runner
的更多信息,请运行以下命令:
nunit3-console.exe --help
更多信息:NUnit 文档