You are here: Home Blog VS2005, Unit Testing and Deployment Items

VS2005, Unit Testing and Deployment Items

by Dan Fairs last modified Jun 22, 2007 02:00 PM
Is it me or are DeploymentItems supremely dodgy?

So there you are, happily coding up your unit tests to check that the new feature that you're about to implement is going to work (because, of course, you always practice test-driven development.) You're working on a data file parser, so your tests use DeploymentItem attributes to push test data files into the test output directory. Maybe your code looks something like this:

[TestMethod()]
[DeploymentItem(@"TestLoader\badquotes.csv")]
[ExpectedException(typeof(ReaderException))]
public void TestBadQuotes()
{
  TestLoader loader = new TestLoader("badquotes.csv"'));
  loader.Load();
}

This test is already working great. So you add a new test, and a new data file, to demonstrate another case you've just thought of:

[TestMethod()]
[DeploymentItem(@"TestLoader\badquotes2.csv")]
[ExpectedException(typeof(ReaderException))]
public void TestBadQuotes()
{
  TestLoader loader = new TestLoader("badquotes2.csv"'));
  loader.Load();
}

You run the tests... and both of them fail!

And this time it's not because you've forgotten that DeploymentItem paths are relative to the containing solution (argh!).

If anyone knows what's going on here, please do let me know. In the meantime I've added it to my list of things for with the only workaround is to restart Visual Studio.

If only that list weren't so long. Maybe it's time to try out SharpDevelop...


Filed under:
Add comment

You can add a comment by filling out the form below. Plain text formatting.