Help for running NUnit from dos command line

I am working on an MSBuilds script to run NUnit tests with CruiseControl.Net. _Test_DAL has three tests.

I am having a problem getting the correct dos command to start NUnit.

Here is the command to run NUnit, but it doesn't find any tests.

D: \ CC \ JCDCHelper \ Source_Test_DAL \ bin \ Debug> "C: \ Program Files \ NUnit 2.4.3 \ bin \ nunit-console" / nologo _Test_DAL.dll

Test Runs: 0, Failure: 0, Downtime: 0, Time: 0.047 seconds

I can use resharper to run tests, so I know the tests are written correctly.

Any help would be awesome.

0


a source to share


3 answers


Returning the answers to the questions, I asked that they were resolved independently.

Now we are using Powershell, but here is how we solved it in case it is useful to anyone



function Invoke-UnitTests  { 

  $NUnitExe = "C:\" + $WhereIsProgramFiles + "\NUnit 2.5.7\bin\net-2.0\nunit-console.exe"
  Show-Status "Invoke-UnitTests was called."
  Show-Status $NUnitExe

  foreach( $OneProject in ( $TestProjects))
  {
    Show-Status "Running unit test for $OneProject"

    $GetCommonDlls = "D:\CC\$AppName\Source\$AppName\_CommonDlls"
    $GetBinDlls = "D:\CC\$AppName\Source\$AppName\Bin"
    Copy-Item "$GetCommonDlls\*" "$WorkingDir" 
    Copy-Item "$GetBinDlls\*" "$WorkingDir" 

    $WorkingDir = "D:\CC\$AppName\Source\$OneProject\obj\$ReleaseOrDebug"
    $NUnitOutput = "D:\CC\$AppName\NUnit\" + $OneProject + ".xml"

    & "$NUnitExe" "$WorkingDir\$OneProject.DLL" /nologo /xml:$NUnitOutput
    if ($lastExitCode -ne 0) 
    {
        Show-Status "NUnit test Command failed for Project:$ProjectName in Application:$AppName"
        Show-Status "Command that failed: ""$NUnitExe"" ""$WorkingDir\$OneProject.DLL"" /nologo /xml:$NUnitOutput"
        Show-Error "Error: Unit test for $OneProject failed"
    }
  }

  Show-Status "All Done with Unit tests"    
}

      

+1


a source


Input files must come first, then parameters.



nunit-console _Test_DAL.dll / nologo

0


a source


I'm not sure how Resharper handles tests, but I do remember TestDriven.Net as being able to "run a test" on methods that weren't actually marked as unit tests. Make sure your class is public and marked with [TestFixture], and that unit test is a public void method marked with [Test].

0


a source







All Articles