Interesting approach.. I usually test extensively the model and not the controller but I guess user-request handling constitutes the big part of this application.
Nice initiative. Your TDD description is however missing the most important step: refactor. Without refactoring after making your tests pass, your code will quickly become unmaintainable.
I also have created a tutorial for learning TDD. It's a bit larger than yours (a Tetris game) and has much more pre-written tests before it's time to write your own tests. Checkout the "tutorial" branch from http://github.com/orfjackal/tdd-tetris-tutorial and follow the instructions in the README file.
This far I've used that as an exercise on one course (http://www.cs.helsinki.fi/u/luontola/tdd-2009/) and it appeared to get the students started in TDD quite nicely. It would be nice to get some feedback from others.
You're becoming a star - We do a webcast on testing called “This week in testing” and this week, we talk about this post about starting TDD.
You’re welcome to watch and comment (http://learn.typemock.com/this-week-in-test/2009/11/18/episode-4-animals-that-talk-back.html) and if you like what you see, please tell the whole world.
For windows developers you also need to change the ":" to a ";" in the arguments for the "Tests" builder. The line should be: -cp .;${workspace_loc:/01_Calculator/lib}/junit.jar AllTests
I don't usually do TDD (I write tests after) and I found it hard to get started with this one. I got a bit into trouble with writing a bunch of tests, then realising I'd rather change the model and ending up with a huge slew of tests that were now nonsensical.
But maybe it's due to my resistance to using a String model for a numeric value. :-)
Interesting approach.. I usually test extensively the model and not the controller but I guess user-request handling constitutes the big part of this application.
ReplyDeleteNice initiative. Your TDD description is however missing the most important step: refactor. Without refactoring after making your tests pass, your code will quickly become unmaintainable.
ReplyDeleteOK, I've already started doing it.
ReplyDeleteA few questions:
What should the tick button do?
Do we have to support more than two operands (e.g 168+152+23)?
I like the test autorunning feature.
I also have created a tutorial for learning TDD. It's a bit larger than yours (a Tetris game) and has much more pre-written tests before it's time to write your own tests. Checkout the "tutorial" branch from http://github.com/orfjackal/tdd-tetris-tutorial and follow the instructions in the README file.
ReplyDeleteThis far I've used that as an exercise on one course (http://www.cs.helsinki.fi/u/luontola/tdd-2009/) and it appeared to get the students started in TDD quite nicely. It would be nice to get some feedback from others.
Hey, I think you already know this, but the Test-First Challenge (http://xp123.com/xplor/xp0201/) can also help getting started on TDD.
ReplyDeleteBTW a nice blog post !
Hi Misko,
ReplyDeleteYou're becoming a star - We do a webcast on testing called “This week in testing” and this week, we talk about this post about starting TDD.
You’re welcome to watch and comment (http://learn.typemock.com/this-week-in-test/2009/11/18/episode-4-animals-that-talk-back.html) and if you like what you see, please tell the whole world.
Thanks,
Gil Zilberfeld
Typemock
Good idea, but it's a shame you didn't write proper build scripts.
ReplyDeleteSome people don't use Eclipse.
"I know it is trivial example, but you need to start someplace."
ReplyDeleteI think that it will be a very good start point to those that are learning TDD, but with a previous knowledgement of JUnit.
:)
For windows developers you also need to change the ":" to a ";" in the arguments for the "Tests" builder. The line should be:
ReplyDelete-cp .;${workspace_loc:/01_Calculator/lib}/junit.jar AllTests
I don't usually do TDD (I write tests after) and I found it hard to get started with this one. I got a bit into trouble with writing a bunch of tests, then realising I'd rather change the model and ending up with a huge slew of tests that were now nonsensical.
ReplyDeleteBut maybe it's due to my resistance to using a String model for a numeric value. :-)