Ignore Irrelevant Return Values

This is an installment in my Zero-Friction TDD series. Sometimes, you don’t care about the return value from a particular operation. The simplest example is if you want to check that creating a new instance of a specific type will throw an exception if supplied with wrong parameter values: [ExpectedException(typeof(ArgumentNullException))][TestMethod]public void CreateWithNullTextWillThrow(){    // Fixture setup   …

1

Microsoft Dynamics Mobile 1.5 Released

If you are wondering about what I’m doing these days, we (the Microsoft Dynamics Mobile Team) just released a new version of Microsoft Dynamics Mobile! And there was much rejoicing 🙂

0

Anonymous Variables

This post is an installment in my series on Zero-Friction TDD. Often when writing a unit test, the SUT‘s API will force you to create objects that you really don’t care about. As an example, take a look at the signature of this constructor: public Plop(int number, string text) To create an instance of the…

7

Naming Direct Output Variables

In my series of Zero-Friction TDD tips and tricks, it’s time to look at naming Direct Output variables. [TestMethod]public void DoStuffWillReturnMessage(){    // Fixture setup    string expectedResult = “ploeh”;    MyClass sut = new MyClass();    // Exercise system    string result = sut.DoStuff(expectedResult);    // Verify outcome    Assert.AreEqual<string>(expectedResult, result, “DoStuff”);    // Teardown} As you can see, I use the…

3

Zero-Friction TDD

Writing good code is difficult. Unit tests are written as code, so a corollary to the first sentence is that writing good unit tests is also difficult. TDD (particularly if you interpret the last D as Design) carries this challenge in abundance, since you ought to be focusing on designing your SUT, but you might…

9

Assert.Throws

xUnit.net provides the Assert.Throws method for testing exceptions, instead of the ExpectedException attribute. In his original announcement, James Newkirk explains why this is a much better approach, and I can only agree. However, those of us that for one reason or another use MSTest are currently stuck with the ExpectedException attribute, but I’ve entered a…

4