4

I am trying to set up a build machine and want to run nunit (on several relatively big and dynamic solutions) from a batch script. I ran the following command lines

"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"

Both gave a 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)

To me it looks like it is looking in the wrong folder:

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

should be

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

Is there a way to specify this in NUnit (or if must be in the solution)?

André C. Andersen
  • 8,955
  • 3
  • 53
  • 79

2 Answers2

2

You can pass the test assembly path as parameter instead of the solution file:

"C:\Program Files (x86)\NUnit 2.6.1\bin\nunit-console-x86.exe" "C:\MyProjectPath\bin\Debug\MyAssembly.dll"
Ufuk Hacıoğulları
  • 37,978
  • 12
  • 114
  • 156
  • 3
    I don't want to do this. I have hundreds of them. I want it to dynamically find the projects of a solution then perform the tests based on this. – André C. Andersen Oct 23 '12 at 14:06
  • @AndréChristofferAndersen It looks like it treats a solution file like a project file. I am not sure what you are trying to do is possible. Maybe you can use [NUnit projects](http://www.nunit.org/index.php?p=projectEditor&r=2.2). – Ufuk Hacıoğulları Oct 23 '12 at 14:20
  • It might be that I am misunderstanding. I assumed that I could make nunit-console.exe run all unit tests associated with a solution file. Might be that my question is evolving to: "How do I run all nunit tests in a solution from the a command line". – André C. Andersen Oct 23 '12 at 14:34
  • @AndréChristofferAndersen That would be more accurate. – Ufuk Hacıoğulları Oct 23 '12 at 14:35
  • 2
    I have been looking in to it and it looks like you are supposed to be able to run a solution file (sln) with nunit-console.exe. I removed the problems I had with the DirectoryNotFoundException by setting up the projects to run on "Any CPU". Now I have a different problem. A problem for tomorrow. Thank you for your time Ufuk. – André C. Andersen Oct 23 '12 at 15:35
0

Don't know if this can be done, but I think that most build servers can do this for you. TeamCity can do that, and I believe others can as well. TeamCity is great and free (up to a certain project limit).

seldary
  • 6,186
  • 4
  • 40
  • 55