locked
App or Plugin For Testing Methods & Other Code RRS feed

  • Question

  • I have a C#/.NET 4.0 project and I want to be able to test the various methods, properties, etc. that are in my application. Unfortunately the Unit Testing built into Visual Studio won't work since I am getting an error when trying to run "Create Unit Test". I've already delved into this and it apparently stems from having some .NET 3.5 components in the project. Unfortunately since they're necessary to this project, I can't remove them.

    I also don't want to have to learn how to create unit test projects, methods and all the other stuff that's necessary to create this big unit test projects. I just want to be able to do some simple code tests. I don't even mind cutting & pasting the method I want to test from my project into a separate application to test it.

    A successful answer would be an application or VS plugin that...

    • Is free
    • Is easy to learn & use

    Nathon Dalton
    Software Developer
    Systems Administrator
    Network Administrator
    Blog: http://nathondalton.wordpress.com
    Thursday, November 11, 2010 5:37 PM

Answers

  • Friday, November 12, 2010 12:42 AM
  • Hi Nathon,

    If you want to start testing in your assembly without MSTest, simply use these two (free) tools / frameworks:

    1) nunit (use NuGet to get it)

    2) Testdriven.net (fastest testrunner for .Net)

    3) the Should framework (optional, but allows for better asserting (use NuGet to get it))

    Once the first two are installed / referenced you create a test class everywhere by simply creating a test like this:

     

    [TestFixture]
    public class Demo_tests
    {
     public void SetUp()
     {
    
     }
    
     [Test]
     public void first_test_name()
     {
      
     }
    }
    
    Note that I'm using underscores in my test names; this is on purpose as it makes for easier BDD reading in my Resharper testrunner (not free, but recommended).

     

    Kind regards,
    Tom de Koning


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Proposed as answer by Tom de Koning Sunday, November 14, 2010 10:25 AM
    • Marked as answer by Nathon Dalton Monday, November 15, 2010 9:50 PM
    Sunday, November 14, 2010 10:22 AM

All replies

  • Friday, November 12, 2010 12:42 AM
  • Hi Nathon,

    If you want to start testing in your assembly without MSTest, simply use these two (free) tools / frameworks:

    1) nunit (use NuGet to get it)

    2) Testdriven.net (fastest testrunner for .Net)

    3) the Should framework (optional, but allows for better asserting (use NuGet to get it))

    Once the first two are installed / referenced you create a test class everywhere by simply creating a test like this:

     

    [TestFixture]
    public class Demo_tests
    {
     public void SetUp()
     {
    
     }
    
     [Test]
     public void first_test_name()
     {
      
     }
    }
    
    Note that I'm using underscores in my test names; this is on purpose as it makes for easier BDD reading in my Resharper testrunner (not free, but recommended).

     

    Kind regards,
    Tom de Koning


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    • Proposed as answer by Tom de Koning Sunday, November 14, 2010 10:25 AM
    • Marked as answer by Nathon Dalton Monday, November 15, 2010 9:50 PM
    Sunday, November 14, 2010 10:22 AM
  • Thank you both for your replies. Sorry for not responding sooner. I've been away for a bit. However, I will check into both of your recommendations and reply back if I have further questions. I sincerely appreciate your answers!
    Nathon Dalton
    Software Developer
    Systems Administrator
    Network Administrator
    Blog: http://nathondalton.wordpress.com
    Monday, November 15, 2010 9:48 PM