Category Archives: Testing

What is the #1 Benefit of TDD?

I was asked this question last Wednesday, when I led a TDD open session at the Israeli Software Craftsmanship User Group. My answer: It makes you think before you write code. In fact, next time somebody asks you what TDD stands for, you answer: Thinking-Driven Development. Sure, all the benefits are there: structured incremental progress,

Read More

Battle of the framework: Testing a Webpart

Time to see the difference between Moles and Isolator code. Let’s start with the code under test (a webpart): public class NewMessagesCountWebPart : WebPart{    private Label lblNewMessages;    protected void CreateChildControls(int i)    {        CreateChildControls();    }       protected override void CreateChildControls()    {        lblNewMessages = new Label();        lblNewMessages.Text = GetMessageNumberText();        this.Controls.Add(lblNewMessages);        base.CreateChildControls();    }    private string GetMessageNumberText()    {        using (SPSite site = new SPSite(“http://sharepoint.typemock.com”))        {            using (SPWeb web

Read More