VSTS Unit Testing

James Newkirk blogs a Hello World unit test sample for Visual Studio Team System. I'm guessing it's no accident that the test code looks a lot like NUnit test code - making it easy to migrate unit tests from NUnit to VSTS makes a lot of sense. However, if I had my druthers, I'd change one thing. I've never liked the fact that the comparison Assert methods (e.g. Assert.AreEqual) take the expected value as the first argument and the actual value as the second. That just feels backward to me. Assert.AreEqual(9, theValue) reads to me like “if (9 == theValue)”. I just don't think that way, and I frequently find myself reversing the parameters inadvertantly. Unfortunately, that change would complicate the migration from NUnit to VSTS, and so probably isn't feasable.

One thing that I hope does carry over from NUnit is the convention that methods that start with the word Test are automatically flagged as test methods (I haven't found documentation about this either way). I like that behavior because it's one less thing to forget - and accidentally leaving off the TestMethod attribute is easy to do, hard to spot, and very impactful. Expansions may help here.

No Comments