Unit Testing in Visual Studio Express 2008

This article has been moved:

New url:

http://www.unit-testing.net/CurrentArticle/How-To-Write-Unit-Tests-In-Visual-Studio-Express.html

Tags: , , , , , , , , , ,

15 Responses to “Unit Testing in Visual Studio Express 2008”

  1. torgeirhelgevold Says:

    Updated:

    I have put out a new version of ExpressUnit:
    More info can be found here:
    http://torgeirhelgevold.wordpress.com/wp-admin/post.php?action=edit&post=15

  2. Pete Says:

    Thanks! Fantastic tool. It would be even better if I could put my tests in my own project, and just use the ExpressUnit project to run them… I am new to C# so do let me know if there’s an obvious way.

  3. torgeirhelgevold Says:

    Hi Pete.
    Based on your comment, I have added some more flexibility to ExpressUnit. (version 1.6)
    You will now be able to define tests in any project in your Visual Studio solution.

    All you have to do is add a reference from your project to the new dll; expressUnitModel.dll. (I have moved the test attributes to this assembly)

    Now, when you run the ExpressUnit project, it will automatically detect tests from any project it has a reference to.

    Tor

  4. Pete Says:

    Fantastic! Thanks.

    And just one more thing that I think would finish it off in making it a really useful tool… If my Confirm.Equals fails, it would be very useful if the GUI would perform a ToString on the two objects provided to it, so it’s obvious why the test failed. This is easy in my native language of Java, I assume it is in C# too….

    Good work :)

  5. torgeirhelgevold Says:

    No problem.
    Thanks for showing interest in the project.

    I have put out a new version with a more meaningful message when Confirm.Equals / Confirm.Different fails

    Tor

  6. torgeirhelgevold Says:

    I have put out a new improved version of ExpressUnit
    Download from http://code.google.com/p/expressunit/

  7. Sagi Says:

    I have just downloaded the project from google code but I don’t know how to install it. I guess I need to grab the ExpressUnitModel.dll from the bin/Release and add a reference to it in my project but I’m not sure regarding the Gui.exe and whether anything else is needed.
    Thanks,

    • torgeirhelgevold Says:

      The easiest way is to just add the ExpressUnitGui project to your solution. (Described as step 1-4 in the article above)
      That way you can add all test to the added project

      • Sagi Says:

        Thanks, I followed the instructions and added a class to the ExpressUnitGui project:

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;

        namespace ExpressUnitGui
        {
        [TestClass]
        public class TimerTest
        {
        [UnitTest]
        public void AddTest()
        {
        Confirm.Equals(4, 2 + 2);
        }

        }
        }

        I’m getting errors about the TestClass and UnitTest attributes not being found.
        Any idea?
        Thanks in advance and sorry if I’m missing something very basic here, I’m a newbie with VC#

    • torgeirhelgevold Says:

      Hi Sagi.
      It looks like you are just missing a using statement.
      Just add the following to the top of the class:

      using ExpressUnitModel;

      This will tell the compiler where the attributes are defined

  8. Sagi Says:

    Cool. That did the trick. Thanks!

    One more question – to get the test to run once the ExpressUnit GUI comes up I need to right-click on the specific test in the left pane and select RUN. Is there a way to get ExpressUnit to run the tests immediately when it comes up?

    • torgeirhelgevold Says:

      I agree. That is a useful feature.
      I have uploaded a new version (ver 2.2) where this is supported.

      Just set the RunTestsAtStartup config setting in app.config in the ExpressUnitGui project to True (The value is case sensitive), and all tests will be run on startup.

      The default value is False

  9. torgeirhelgevold Says:

    Soon I will post a new blog entry describing how to set up continuous Integration with ExpressUnit and Hudson

  10. Fernando Zamora Says:

    Hey Torgeir,

    First off let me thank you for a great resource.

    It would be great if your application would simply read the nUnit Attributes and run the classes as they are configured to nUnit. That way we could have our tests setup for nUnit but run them with your runner. I could help if you’d like.

    • torgeirhelgevold Says:

      Hi Fernando.
      Thanks checking out ExpressUnit.

      I think for what you are trying to do, it may make more sense to just download the NUnit source code for the GUI/Console runner, and include it in your project. I haven’t tried it, but it seems like you should be able to debug your tests if you run against the source code rather than the pre-built version of the test runner.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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


Follow

Get every new post delivered to your Inbox.