I am using Cruisecontrol for building code and executing ~200 test cases.
Sometimes the build gets hung due to some of the test cases and I am not able to determine which test case it is.
Is it possible to print the name of the currently executing test case without modifying the current test case code?
If yes, how?
I'm assuming you are using NUnit to do your tests. If so, instead of using the <nunit>
block in the CruiseControl config, use the <exec>
task. In the <buildArgs>
element, include the /labels command line argument. This will print the info to the server log.
Instead of using:
<nunit>
<path>C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-console.exe</path>
<assemblies>
<assembly>C:\Projects\Personal\MyTestApp\MyTestApp.Tests\bin\Debug\MyTestApp.Tests.dll</assembly>
</assemblies>
</nunit>
Use:
<exec>
<executable>C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-console.exe</executable>
<buildArgs>/labels C:\Projects\Personal\MyTestApp\MyTestApp.Tests\bin\Debug\MyTestApp.Tests.dll</buildArgs>
</exec>
I know it isn't ideal, but it will print each test as it runs to the log. You can then use the merge task to merge the xml file output by nunit into your build log.
Try doing this using the ccnet console application first, so you can see the output in real time. It should help you see what you are looking for.
It might also be good to submit a patch to CruiseControl to add the following line to the "project\core\tasks\NUnitArgument.cs" file:
line: 53 argsBuilder.AddArgument("/labels");
Or you could just add that line, build CruiseControl and use your own version.
TestContext.CurrentContext.Test.Name will help in identifying the currently executing test case. Putting
Console.WriteLine("Currently Executing Test Case : " + TestContext.CurrentContext.Test.Name);
in method with SetUp attribute will print the UT currently executing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With