Reputation: 14399
I am working on an MSBuilds script to run my NUnit tests from CruiseControl.Net. _Test_DAL has three tests in it.
I am having problem getting the right dos command to run the NUnit.
Here is the command to run NUnit but it does not 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
Tests run: 0, Failures: 0, Not run: 0, Time: 0.047 seconds
I am able to use resharper to run the tests, so I know the tests are written correctly.
Any help would be awesome.
Upvotes: 0
Views: 3148
Reputation: 14399
Going back answering questions i asked that were solved independantly.
We use Powershell now, but here is how we solved it in case it's 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"
}
Upvotes: 1
Reputation: 12328
I'm not sure how Resharper handles tests, but I do recall TestDriven.Net as being able to 'run test' on methods that were not actually marked as unit tests. Make sure your class is public and marked as a [TestFixture], and that the unit test is a public void method marked as a [Test].
Upvotes: 0
Reputation: 10230
The input files have to go first, then the options.
nunit-console _Test_DAL.dll /nologo
Upvotes: 0