Debugging NUnit test within C# Express

Apperently there was a time when the TestDriven.Net put the context menus in all the studio products, including the Express Editions.  When did that feature get pulled?  It looks like after the RTM of Express.  There’s a dialog that pops up during installation that allows you to reset the menus, leave them the way they are or cancel.  I even had an older version of TestDriven, but the all do the same thing.

What we have to do is explained on Charlie Poole’s blog on entitled Running NUnit Automatically in C# Express.  You basically fire up the GUI from inside a project.  Hence the reason for our Kenthall.TestHelper assembly, and that’s all it does for now.


6 Responses to Debugging NUnit test within C# Express

  1. Blokeley says:

    There is an easy way to debug NUnit tests from Visual C# Express, which has the advantages of:
    * not invoking the NUnit GUI; and
    * not popping up an external console window; and
    * piping output to Visual Studio’s output window; and
    * not requiring hacking the .csproj file…


    0. Add a reference to nunit-console-runner in your test assembly.

    1. In your test assembly, make a class with the following one liner:

    using System;

    namespace MotorExampleTests

    // Written by blokeley
    class NUnitConsoleRunner
    static void Main(string[] args)

    2. Open your test assembly’s properties. For example, right-click on the assembly and select Properties.

    3. On the Application tab, select Output Type: Windows Application; and Startup Object: NUNitConolseRunner (the file above).

    4. On the Debug tab, enter the .csproj file name in Command Line Arguments; and browse to the folder of the .csproj file in Working Directory.

    5. Save everything, set a breakpoint and run using F5 or the green arrow button.

  2. mac671 says:

    Thanks a lot!

    This is very usefull :).

    I’ve been using some free tools to debug unit tests, but unfortunately I have lots of interpoeration with GUI elements, and the free-test running tools that I’ve used so far have given ambigous errors where NUnit framework worked fine
    ( butI did not debug it I was only running my tests form GUI mode)

    Now I don’t have to worry that the result of the test under debug mode will be different form the one used in NUnit.

    Thank you very much!

  3. sam says:

    I am following the approach mentioned in by Blokeley in the comment section. I am successfully running the unit tests by pressing the green arrow button – no problem with that. But I have some questions:

    (1) I have the project named as UnitTests, which contains the file mentioned in the comment. After compilation (or pressing F5), I see a UnitTests.exe in the Debug and Release folder. But if I try to run the exe directly by opening a command prompt, nothing happens. Nothing shows up on the console and I get back the prompt.

    How can I modify the code so that I can run the tests from command line as well? Is it possible?

    (2) Is there an option I can set in the nUnit (through the above program) so that the test results automatically get captured in a log file?


  4. David says:

    Something similar could be done for NUnit GUI version.

    The idea is the same. Try to invoke NUnit from whithin C# environment.

  5. David says:

    Sorry the exact location is below:

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: