c# - 如何让 nunit-console 在\bin\Debug\而不是\bin\x86\Debug 中查找程序集?

标签 c# .net unit-testing nunit

我正在尝试设置构建机器并希望从批处理脚本运行 nunit(在几个相对较大且动态的解决方案上)。我运行了以下命令行

"C:\Program Files (x86)\NUnit 2.6.1\bin\nunit-console-x86.exe" "C:\MySolutionPath\MySolution.sln"
"C:\Program Files (x86)\NUnit 2.6.1\bin\nunit-console.exe" "C:\MySolutionPath\MySolution.sln"

两者都给出了 System.IO.DirectoryNotFoundException:

NUnit-Console version 2.6.1.12217
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment -
   OS Version: Microsoft Windows NT 6.1.7601 Service Pack 1
  CLR Version: 2.0.50727.5456 ( Net 3.5 )

ProcessModel: Default    DomainUsage: Default
Execution Runtime: net-3.5
Unhandled Exception:
System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\MyProjectPath\bin\x86\Debug\MyAssembly.dll'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean
 useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, St
ring msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   at NUnit.Core.AssemblyReader.CalcHeaderOffsets()
   at NUnit.Core.AssemblyReader..ctor(String assemblyPath)
   at NUnit.Util.RuntimeFrameworkSelector.SelectRuntimeFramework(TestPackage package)
   at NUnit.Util.DefaultTestRunnerFactory.GetTargetProcessModel(TestPackage package)
   at NUnit.Util.DefaultTestRunnerFactory.MakeTestRunner(TestPackage package)
   at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
   at NUnit.ConsoleRunner.Runner.Main(String[] args)

对我来说,它看起来像是在错误的文件夹中查找:

C:\MyProjectPath\bin\x86\Debug\MyAssembly.dll

应该是

C:\MyProjectPath\bin\Debug\MyAssembly.dll

有没有办法在 NUnit 中指定它(或者如果必须在解决方案中)?

最佳答案

您可以将测试程序集路径作为参数而不是解决方案文件传递:

"C:\Program Files (x86)\NUnit 2.6.1\bin\nunit-console-x86.exe" "C:\MyProjectPath\bin\Debug\MyAssembly.dll"

关于c# - 如何让 nunit-console 在\bin\Debug\而不是\bin\x86\Debug 中查找程序集?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13032056/

相关文章:

c# - SmtpClient.SendAsync - 如何在触发回调之前停止应用程序退出?

c# - Roslyn 分析器仅针对打开的文件运行

c# - 如何在azure中移动目录并在azure文件共享中使用ShareDirectoryClient对其进行ZIP

c# - 模态进度表显示 IProgress 并支持取消 WinForms 的异步任务

c# - C# : generate a list of two dimension arrays with the same shape 中的 FsCheck

php - Laravel 模型工厂使用相同的种子进行测试

代码或 IIS 6 中的 c# 缓存控制

c# - 以编程方式设置 ASP.NET 计时器间隔

c# - .NET Core 中当前位置的堆栈跟踪

java - 为什么我的 JUnit 测试没有在 Eclipse 中运行?