Jun 22

VS2005, Unit Testing and Deployment Items

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 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...


This won't be published anywhere, it's just in case I need to contact you.

You can use Markdown in your comments. Be sensible!

Sorry about this, but I don't want spam comments.