Nunit忽略命令行参数进行配置

时间:2012-06-18 15:36:08

标签: command-line nunit jenkins

我在jenkins工作中尝试使用nunit时遇到了一些问题。尽管nunit-2.6 [1]的文档指出,您可以指定要用于测试的构建配置,但这似乎不起作用。我尝试使用“Release”配置运行测试,但是nunit尝试加载Debug程序集并失败:(我通过以下调用启动nunit:

nunit-console-x86.exe ambiHomeWPFTest\Tests\Tests.csproj /config:Release

任何人都有想法,那里发生了什么?我对来自java背景的.NET很陌生,所以也许我会想念一些简单的东西。

[1] http://www.nunit.org/index.php?p=consoleCommandLine&r=2.6

[test_ambiHomeWPFTest_master] $ cmd /c call     C:\Windows\TEMP\hudson8704126216198591607.bat

c:\jenkins\workspace\test_ambiHomeWPFTest_master>nunit-console-x86.exe ambiHomeWPFTest\Tests\Tests.csproj /config:Release 
NUnit-Console version 2.6.0.12051
Copyright (C) 2002-20011 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: Ein Teil des Pfades     "c:\jenkins\workspace\test_ambiHomeWPFTest_master\ambiHomeWPFTest\Tests\bin\Debug\Tests.dll    " konnte nicht gefunden werden.
   bei System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   bei System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32     rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options,     SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
   bei System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
   bei NUnit.Core.AssemblyReader.CalcHeaderOffsets()
   bei NUnit.Core.AssemblyReader..ctor(String assemblyPath)
   bei NUnit.Util.RuntimeFrameworkSelector.SelectRuntimeFramework(TestPackage package)
   bei NUnit.Util.DefaultTestRunnerFactory.GetTargetProcessModel(TestPackage package)
   bei NUnit.Util.DefaultTestRunnerFactory.MakeTestRunner(TestPackage package)
   bei NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
   bei NUnit.ConsoleRunner.Runner.Main(String[] args)

c:\jenkins\workspace\test_ambiHomeWPFTest_master>exit -100 
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE

1 个答案:

答案 0 :(得分:1)

如果在/config:命令中引用.csproj时遇到nunit-console-x86开关问题,我建议您明确引用感兴趣的DLL。

在上面的场景中,呼叫应该是:

nunit-console-x86 ambiHomeWPFTest\Tests\bin\Release\Tests.dll