From: Pat Maddox Date: 2007-01-24T10:36:36+09:00 Subject: Re: I don't get rspec On 1/23/07, Eric Hodel wrote: > On Jan 23, 2007, at 16:26, James Edward Gray II wrote: > > On Jan 23, 2007, at 6:10 PM, Joe Van Dyk wrote: > >> What's wrong with zentest, specifically? > > > > You will probably understand better by watching the movie, but > > zentest encourages you to make a test case for each class and a > > test method for each method. > > Which will match up 1:1 if you factor your code well. The point is that you shouldn't try to shoehorn your tests into this 1:1 approach. You brought up the tutorial as an example of specs that match up nicely with the code, but even that ends up with a few contexts. If you just have a StackTest class, you won't get the same logical separation. How many programmers are going to write an EmpyStackTest class, a OneItemStackTest class, a FullStackTest class, etc? As your behavior becomes more complex - by interacting with other objects - you need to be able to drill a bit deeper with your specifications. I often have one complete context for an individual method. Not many programmers will create a new test class just to spec a method. And that doesn't mean that this method is too tightly coupled to other objects, it just means that you need more finely-grained specifications. > BDD presents a method of thinking about test design to help you focus > on better object design and object modeling. Unit testing doesn't > have this method of thinking built-in, you have to discover it. The bottom line is that if you're using either Test::Unit or RSpec the most effectively, you're probably doing things nearly the same way that you would with the other framework. The difference is that RSpec guides you to the proper way. Unit testing doesn't have the proper thinking built-in, as you said. The BDD guys give us a testing tool with some of the lessons they've learned over the years built-in. It's just a different path to the same place. Pat