TestDriven.Net

I’ve been working on a number of things over the last couple of weeks but just haven’t got around to blogging about what I’ve been finding out… lots of little notes here and there so when I get around to it I’ll have to put them up.

One tool that everyone should have is TestDriven.Net – http://www.testdriven.net/ย – this is a welcome partner to both NUnit or the VS2005 Test tools. It installs a right click test option into the VS menu allowing you to run tests, run methods as tests, debug into tests, etc. It’s fast (execution and usability wise) and seems very stable (never had a crash even though the site currently lists it as Beta for 2.0). One feature I really like is it gives an error when a test fails that you can click on and it takes you straight to the part of the test that failed – Its one tool that I’m using more and more all the time.

One thing I did come across yesterday when I was running my tests from the right click menu tricked me for a while. You can tag a test with the attribute [ExpectingException(typeof(ExceptionTypeHere))] – the problem is if the class is not marked as public the test will always fail – even though the exception is thrown. Obviously the class had to be marked as public anyway but it was just something I missed when I created my class since VS normally leaves it off when you go right click new class ๐Ÿ™‚ So if you are using ExpectingException and getting some weird failing tests then make sure the test class is marked as public! ๐Ÿ™‚ Some stub code off the top of my head…

using NUnit.Framework;

[TestFixture]
public class TestClass // Make sure this public is here!
{

[Test]
[ExpectingException(typeof(ArgumentException))]
public void ArgumentExceptionTest()
{ … }
}

Advertisements

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 )

Google+ photo

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

Connecting to %s


%d bloggers like this: