This article has been moved:
New url:
http://www.unit-testing.net/CurrentArticle/How-To-Write-Unit-Tests-In-Visual-Studio-Express.html
Tags: Continuous Integration Visual Studio Express, Debug Unit Tests, ExpressUnit, Run tests on check-in Visual Studio Express, TDD, TDD Visual Studio, Test Driven Development, Torgeir Helgevold, Unit test, Unit testing Visual Studio Express, Unit Testing Visual Studio Express 2008
June 11, 2008 at 3:50 am |
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
February 28, 2009 at 1:49 pm |
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.
March 1, 2009 at 2:21 am |
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
March 1, 2009 at 9:32 am |
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
March 2, 2009 at 12:08 am |
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
March 13, 2009 at 3:17 am |
I have put out a new improved version of ExpressUnit
Download from http://code.google.com/p/expressunit/
May 12, 2009 at 8:10 pm |
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,
May 13, 2009 at 4:45 am |
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
May 14, 2009 at 7:50 pm
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#
May 15, 2009 at 3:25 am |
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
May 15, 2009 at 5:18 am |
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?
May 16, 2009 at 1:21 am |
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
May 26, 2009 at 1:31 am |
Soon I will post a new blog entry describing how to set up continuous Integration with ExpressUnit and Hudson
March 26, 2010 at 8:50 am |
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.
March 28, 2010 at 3:53 pm |
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.