tag:blogger.com,1999:blog-3075419760307323302.post1393205943911488076..comments2023-06-17T06:22:17.460-04:00Comments on Wunda's World: I taught my husband TDD todaywendyhttp://www.blogger.com/profile/12983025600472588046noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-3075419760307323302.post-72838500278599478332007-06-17T11:47:00.000-04:002007-06-17T11:47:00.000-04:00Edward,That is very similar to what we came up wit...Edward,<BR/><BR/>That is very similar to what we came up with :)<BR/><BR/>Thanks for the contribution!wendyhttps://www.blogger.com/profile/12983025600472588046noreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-60873379821848987122007-06-17T10:14:00.000-04:002007-06-17T10:14:00.000-04:00mockery is an odd choice for the name of the MockR...mockery is an odd choice for the name of the MockRepository memberAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-47911844650913652282007-06-16T19:25:00.000-04:002007-06-16T19:25:00.000-04:00I sat down to try to imagine what code you would h...I sat down to try to imagine what code you would have written and came up with the following. I wonder how similar this is to the real code.<BR/><BR/>---<BR/><BR/>using Rhino.Mocks;<BR/>using NUnit.Framework;<BR/><BR/>namespace TddHelloWorld<BR/>{<BR/> public interface IConsole<BR/> {<BR/> void WriteLine(string text);<BR/> }<BR/><BR/> public class Greeter<BR/> {<BR/> IConsole console;<BR/><BR/> public Greeter(IConsole console)<BR/> {<BR/> this.console = console;<BR/> }<BR/><BR/> public void GreetTheWorld()<BR/> {<BR/> console.WriteLine("Hello, World!");<BR/> }<BR/> }<BR/><BR/> [TestFixture]<BR/> public class GreeterFixture<BR/> {<BR/> MockRepository mockery;<BR/><BR/> [SetUp]<BR/> public void SetUp()<BR/> {<BR/> mockery = new MockRepository();<BR/> }<BR/><BR/> [Test]<BR/> public void GreetTheWorldShouldTellTheConsoleToEmitHelloWorld()<BR/> {<BR/> IConsole console = mockery.CreateMock<IConsole>();<BR/><BR/> using (mockery.Record())<BR/> {<BR/> console.WriteLine("Hello, World!");<BR/> }<BR/><BR/> using (mockery.Playback())<BR/> {<BR/> Greeter greeting = new Greeter(console);<BR/> greeting.GreetTheWorld();<BR/> }<BR/> }<BR/> }<BR/>}Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-19565559304848610422007-06-16T00:20:00.000-04:002007-06-16T00:20:00.000-04:00TDD isn't easy. I thought I got it but that was wh...TDD isn't easy. I thought I got it but that was when my team consisted of 1 pair on a business app and even then we started mid way through the project.<BR/><BR/>With a few more people and a lot more GUI new challenges arose. It's hard to read everyone styles. Even my own because I keep changing my mind on what's a good test.<BR/><BR/>Sometimes the tests make me avoid changes I think are easy. The problem with that statement is if the test is complex the code probably doesn't follow the one responsibility rule. So one change may be easy, but without a refactor, each "easy" change is going to be harder and harder.<BR/><BR/>The thing to remember if you are learning is to shift thinking away from TDD as QA to TDD as design.<BR/><BR/>How your tests read is very important to introducing and getting it to stick on a team. My coworker Lee said, he often still goes to the code to figure out what something is doing and not the tests.<BR/><BR/>Readability is highly important to TDD. If your classes don't have single responsibility your test setup is going to be ugly and unreadable. Its going to be hard to maintain, and even harder to refactor without just rewriting the tests.<BR/><BR/>I first blamed the indirection and DRY applied to test code but Wendy correctly pointed out that was the result of the class under test was too complex.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-58566790066018751602007-06-15T12:19:00.000-04:002007-06-15T12:19:00.000-04:00Russ,You're not alone, visualizing the process is ...Russ,<BR/><BR/>You're not alone, visualizing the process is really, really hard. I learned by practicing (a lot) on my own and it was painful. <BR/><BR/>If its something thats encouraged in your environment, see if your company will bring in an expert to get your team started with testing.wendyhttps://www.blogger.com/profile/12983025600472588046noreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-13308328874428300412007-06-15T12:14:00.000-04:002007-06-15T12:14:00.000-04:00Edward,The test looked very similar except:1. Cons...Edward,<BR/><BR/>The test looked very similar except:<BR/><BR/>1. Construction of our mock class instead of the Rhinomock<BR/>2. Expectation of the RhinoMock before executing the helloworld method<BR/>3. Using an Assert in our mock class to verify instead of Verify(mock)<BR/><BR/>When we first started, I spent a good deal of time discussing the name, how it should address what we're actually testing, etc. You know what? It didn't make any sense to start like that... <BR/><BR/>Names help you know what you're testing and understand a classes responsibilities, but you need to understand testing well to figure out what names help you most. Our test was called Test.wendyhttps://www.blogger.com/profile/12983025600472588046noreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-55040310511666479692007-06-15T11:49:00.000-04:002007-06-15T11:49:00.000-04:00Bill,When I was teaching my husband I did think ou...Bill,<BR/><BR/>When I was teaching my husband I did think our interaction would have been very interesting to post. Maybe next time I will do that.wendyhttps://www.blogger.com/profile/12983025600472588046noreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-55432527954548768142007-06-15T11:45:00.000-04:002007-06-15T11:45:00.000-04:00You guys are just amazing... I know this comment r...You guys are just amazing... I know this comment really doesn't add to the conversation but I had to say this out loud :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-91946287263237052542007-06-12T12:06:00.000-04:002007-06-12T12:06:00.000-04:00This is an interesting blog, thanks Wunda!I too am...This is an interesting blog, thanks Wunda!<BR/><BR/>I too am interested in TDD but not really being in an environment where that kinda things encouraged (everyone talks about how cool it is, but no-one does it!) I really have a hard time visualising the process.<BR/><BR/>Could we see your code for this, perhaps you could compose a blog entry narrating the process that you and your extremely lucky Husband went through!<BR/><BR/>Thanks in advance.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-87567053268209892132007-06-12T11:53:00.000-04:002007-06-12T11:53:00.000-04:00I am interested to know what the tests looked like...I am interested to know what the tests looked like both before and after introducing RhinoMocks.<BR/><BR/>I am also interested in the test names - they seem to somehow drive the tests in many of the examples I see.<BR/><BR/>I am so close to 'getting' TDD and each example I see moves me one step closer.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-65960233015637857152007-06-10T10:19:00.000-04:002007-06-10T10:19:00.000-04:00I liked this post. Any way of saying the same less...I liked this post. Any way of saying the same lesson from a different point of view is helpful. I'm still struggling in the solution.<BR/><BR/>Have you ever webcast any of your TDD teachings? I would really be interested in that!Anonymoushttps://www.blogger.com/profile/02934801499751086516noreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-50562355977390165792007-06-09T19:49:00.000-04:002007-06-09T19:49:00.000-04:00Scott,Thanks for this comment, it made me realize ...Scott,<BR/><BR/>Thanks for this comment, it made me realize that this post wasn't illustrating what I wanted it to -- a different way for me to approach teaching tdd and how well it worked.wendyhttps://www.blogger.com/profile/12983025600472588046noreply@blogger.comtag:blogger.com,1999:blog-3075419760307323302.post-82651585913439608712007-06-09T18:09:00.000-04:002007-06-09T18:09:00.000-04:00Pairing shouldn't be about talking someone through...Pairing shouldn't be about talking someone through the design. Talking someone through design, and the sheer desire to be talked through a design or an approach rather than cooperatively surfacing and refining it is yet another kind of waterfall thing.<BR/><BR/>Design in micro increments can't be disembodied and transmitted independently of the implementation exercise. That kind of thing is the predisposition of phased-based, chunky design approaches.<BR/><BR/>Next time, you should be firm with him. Either he accedes to his own novice-ness and submits to your agile authoritay, or no pairing for a week :)Anonymoushttps://www.blogger.com/profile/10851121926952875016noreply@blogger.com