Writing test cases and testing methods. RRS feed

  • Question

  • I am a newbie in Unit Testing. I am working on an old project written on Visual Studio 2005 (.NET-2.0). I am using NUnit to test various methods. As opposed to VS-2010, there is no way to add a separate testing project in existing solution explorer.

    I am referring to NUnit documentation, where it states to add a reference to NUnit Framework like:

    using NUnit.Framework;

    Then, add [TestFixture] attribute above the method declaration.

    I feel this approach quite cumbersome as I need to modify my original code and after testing I need to remove these extra words.

    Is there any better way to test a VS-2005 application?



    Sunday, October 23, 2011 5:16 AM

All replies

  • Hi OldEnthusiast,

    The attribute '[TestFixture]' will be decorated on the new tests that you write and not on the methods that you want to test. For example in Namespace MyVs2005.Application you had a class1 which had method1 that you wanted to test. 

    You would create a new test project add a reference to Nunit in the dll references.

    The TestFixture attribute - This is the attribute that marks a class that contains tests and, optionally, setup or teardown methods.

    Create a new test class and then,


    public void TestClass1Method1Assert()


    // you test logic and assertion.


    Since you are already using VS 2005, why not use the visual studio testing framework, documentation and help here => Msdn has got some very nice walkthroughs here, http://msdn.microsoft.com/en-us/library/ms182515(v=VS.80).aspx

    Cheers, Tarun 

    Please remember to mark the replies as answers if they help.

    Tarun Arora

    Blog: http://geekswithblogs.net/TarunArora  Subscribe in a reader

    Sunday, October 23, 2011 2:57 PM