Search the web
Sign In
New User? Sign Up
extremeprogramming · Extreme Programming
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Click here for the latest updates on Groups Message search

Messages

  Messages Help
Advanced
Behaviour Driven Development   Message List  
Reply Message #113105 of 153365 |
Re: [XP] Behaviour Driven Development

Hi Renzo,

I'm working on JBehave in my spare time, so the whole BDD thing is very
big for me. I'd like to make a suggestion which I think will help you to
understand the paradigm shift better.

For clarity, here's a summary of your methods:

shouldAddToListImpl
shouldCallSizeAndHaveSizeOfOne
shouldFoundStarWars

But these aren't descriptive of the behaviour of the class - they're named
after the acceptance criteria. To describe the behaviour of the class
better, I'd call them:

shouldBeEmptyWhenFirstCreated
shouldHaveASizeEqualToTheNumberOfItemsAdded
shouldProvideAnIteratorOverAnyItemsAdded

etc.

You might add one item and expect to see a size of 1, but that's not the
behaviour you're designing; it's just one way that you can specify an
acceptance criteria for that behaviour. By naming the methods after the
behaviour, not the acceptance criteria, it's easier to see how the class
should perform and what its responsibilities are. I don't think it really
matters whether you use mocks, stubs or the real code here, nor do I think
it matters whether you add one, two or three items, as long as you can
verify, when you're done, that the class behaves as expected.

Does this help describe the shift in thinking of BDD?

Thank you for posting this, BTW. I've been telling everyone that you can
try out BDD by using "should" instead of "test", and the rest will
automatically follow; now I can see that it isn't true at all. I guess
I've always thought in terms of BDD, which is why I'm so passionate about
it, but it makes it very hard for me to understand why people "don't get
it" (or indeed, what it is that they "don't get").

Your example has illuminated my problem and given me new insight. I hope
I've helped with yours.

Regards,
Liz.

--
Elizabeth Keogh
ekeogh@...
http://www.livejournal.com/users/sirenian


extremeprogramming@yahoogroups.com wrote on 30/09/2005 11:16:48:

> Well, I've read the paper. Thank you for pointing out the focus shift
> from "verification" to "specification". Anyway what I'm seeing here
> is a shift in the way to write state tests instead of a paradigm shift.
>
> Maybe I'm wrong but when I talk about testing behaviour, I'm thinking
> at something closer to mock driven developing, where the "Context" is
> an object instance along with its relationships to other instances
> and the way this network reacts to external stimuli. (for an in-depth
> look here http://www.jmock.org/oopsla2004.pdf for example).
>
> Now, why not to use the shift in writing test cases that Dave is
> describing to do mock behavioural testing? What I'm saying is that
> for example:
>
> class OneMovieList < Spec::Context
> def setup
> @list = MovieList.new
> star_wars = Movie.new "Star Wars"
> @list.add star_wars
> end
> def should_have_size_of_1
> @list.size.should_equal 1
> end
> def should_include_star_wars
> @list.should_include "Star Wars"
> end
> end
>
> is roughly equivalent in Java/Junit (sorry I don't know Ruby :) to:
>
> class OneMovieList extends Context {
> MovieList _movieList;
> void setUp() {
> _movieList=new MovieList();
> _movieList.add("Star Wars");
> }
> public void shouldHaveSizeOfOne() {
> shouldEqual(1, _movieList.size());
> }
> public void shouldIncludeStarWars() {
> shouldInclude("Star Wars", _movieList.iterator());
> }
> }
>
> that seems to me plain old state testing written with a different
> (and clearer) syntax. Now, what about this:
>
> class OneMovieList extends Context {
> MovieList _movieList;
> ArrayList _movieListMockImpl;
> void setUpState() {
> _movieList=new MovieList();
> _movieListMockImpl=mock(MovieListImpl.class);
> _movieListMockImpl.forwardTo(new ArrayList());
> _movieList.setListImpl(_movieListMockImpl);
> _movieList.add("Star Wars");
> _movieList.size();
> _movieList.contains("Star Wars");
> }
> public void shouldAddToListImpl() {
> shouldReceiveMessage("add", _movieListMockImpl).once();
> }
> public void shouldCallSizeAndHaveSizeOfOne() {
> shouldReceiveMessage("size", _movieListMockImpl).andReturn(1);
> }
> public void shouldFoundStarWars() {
> shouldReceiveMessage("contains", _movieListMockImpl)
> .with("Star Wars").andReturn(true);
> }
>
> In my opinion, the last OneMovieList class does behavioural testing
> as well as state tesing (and you can choose how deep to go with any
> of them). Just some thoughs.
>
> Bye
> Renzo



[Non-text portions of this message have been removed]




Fri Sep 30, 2005 11:22 am

deathbypeaches
Offline Offline
Send Email Send Email

Message #113105 of 153365 |
Expand Messages Author Sort by Date

Well, I've read the paper. Thank you for pointing out the focus shift from "verification" to "specification". Anyway what I'm seeing here is a shift in the way...
Renzo Borgatti
renzo_borgatti
Online Now Send Email
Sep 30, 2005
10:25 am

Hi Renzo, I'm working on JBehave in my spare time, so the whole BDD thing is very big for me. I'd like to make a suggestion which I think will help you to ...
Elizabeth Keogh
deathbypeaches
Offline Send Email
Sep 30, 2005
11:25 am

Hi all, I *still* don't get it. I have read Dave's paper and while I respect Dave immensely, this particular paper looked a little "thin" to me. Do correct me...
Ravi Mohan
magesmail
Offline Send Email
Oct 2, 2005
8:47 am

... Hi Ravi, If I understand what Elizabeth is saying, which maybe I don't, the important difference is not between a well chosen testXXX and shouldXXX. The...
BenAveling
ben_aveling
Offline Send Email
Oct 2, 2005
11:40 am

Ben, Thank you for your comments. Much appreciated. <some nice comments snipped> ... Got it. But I guess one could write bad "should" tests as well. And does...
Ravi Mohan
magesmail
Offline Send Email
Oct 2, 2005
12:19 pm

... Of course. The question for me is "Does using should instead of test make it easier to write good tests." At the moment, I don't know. testInitialState...
BenAveling
ben_aveling
Offline Send Email
Oct 2, 2005
1:11 pm

<Abject Apolgies if this is a repost. I was using a different id and yahoo didn't even warn me I wasn't a member of this group using that id . Sorry again> ...
Ravi Mohan
magesmail
Offline Send Email
Oct 2, 2005
2:19 pm

... It depends on how you phrase the desired result. You chose "laneReset", but that doesn't tell me what about the lane reset behavior we are interested in....
David Chelimsky
dchelimsky
Offline Send Email
Oct 2, 2005
3:22 pm

David, ... Well, maybe that has more to do with the fact that a)English is not my native tongue, and b) I was just typing it out as I composed the mail than...
Ravi Mohan
magesmail
Offline Send Email
Oct 2, 2005
4:32 pm

Hi Ravi, One thing that occurs to me here is that you already have a good understanding of the difference between state and behavior in specifications and so...
David Chelimsky
dchelimsky
Offline Send Email
Oct 2, 2005
4:58 pm

David, ... Not really. My concern is with the thesis that the use of "should" automatically (or to alarger degree) promotes behavioral naimg of tests . I have...
Ravi Mohan
magesmail
Offline Send Email
Oct 2, 2005
5:11 pm

... Aye, there's the rub. I've played around with some ideas, wrapping assertions up in methods that express something closer to the rspec methods. Right now,...
David Chelimsky
dchelimsky
Offline Send Email
Oct 2, 2005
7:56 pm

Hi David, ... [snip] As I understand, what you said is: * there are state specification and behavior specification * shouldXXXX form naming encourages behavior...
June Kim
junaftnoon
Offline Send Email
Oct 4, 2005
12:45 am

... It's not that all state tests are inherently more brittle than all behavior tests. It's that behavior tests CAN lead you in a direction in which less...
David Chelimsky
dchelimsky
Offline Send Email
Oct 4, 2005
2:48 am

Hi June, ... As far as I can understand now (and I'm writing here to let others say if I'm right) interaction-based testing as Martin Fowler describes in his...
Renzo Borgatti
renzo_borgatti
Online Now Send Email
Oct 6, 2005
9:36 am

... Part of the idea here is that they are not <"should" tests> but rather, simply, "shoulds". ... The goals of BDD (as I see them) are not to simply replace a...
David Chelimsky
dchelimsky
Offline Send Email
Oct 2, 2005
1:55 pm

... Ironically, I took the "in progress" idea from Dale's post but didn't follow it through. Perhaps this should read: class SpecifyInitialStateOfGame <...
David Chelimsky
dchelimsky
Offline Send Email
Oct 2, 2005
2:12 pm

... I don't know if anyone has pointed this out, but SUnit (at least the early versions) used "should" rather than "assert." Michael Feathers ...
Michael Feathers
mfeathers256
Offline Send Email
Oct 2, 2005
2:31 pm

Hi Ben, ... The primary principle I use to organize tests is The Principle of Rapid Fault Identification: If one or more of these assertions were to fail,...
Dale Emery
dalehemery
Offline Send Email
Oct 2, 2005
12:28 pm

... The essence of BDD is to take TDD and change the testing terms to specification terms. The goal is to see how we as programmers behave differently thinking...
J. B. Rainsberger
nails762
Offline Send Email
Oct 2, 2005
8:54 pm

Joe, ... No argument there. I was asking about any experiential evidence that such a change causes a real difference. ... And which version of the Sapir-Whorf...
Ravi Mohan
magesmail
Offline Send Email
Oct 3, 2005
3:25 am

... I'm not Dave, but I believe this is a correct statement: no conclusions of any kind yet. It's just an informal experiment. ... As far as I know, the tools...
J. B. Rainsberger
nails762
Offline Send Email
Oct 3, 2005
3:01 pm

Joe, ... Ok. ... Well I guess sthat restricts the subset of possible responders to those who advocate a "BDD is better than TDD" position and/or are working on...
Ravi Mohan
magesmail
Offline Send Email
Oct 3, 2005
3:32 pm

... I think it's worth trying. It's easy to forget that design is between the ears. I don't know if any of us really know how much little things in the...
Michael Feathers
mfeathers256
Offline Send Email
Oct 3, 2005
5:53 pm

Hi Ravi, ... There's not much difference betweeen these two conventions, no. Dan North and I have had a long discussion, as have others, about using the word ...
Elizabeth Keogh
deathbypeaches
Offline Send Email
Oct 3, 2005
10:05 am

... I've not yet tried the BDD notion, but I expect this to be a strong effect. Might have to figure a way to do BDD in Ruby to be sure. I feel that Dave's...
Ron Jeffries
RonaldEJeffries
Offline Send Email
Oct 3, 2005
11:35 am

Ron, ... If you do, I hope you write it up. That would be an extremely interesting article. ... I hope I understood this correctly. Are you saying(intuiting)...
Ravi Mohan
magesmail
Offline Send Email
Oct 3, 2005
2:04 pm

... Well, I wouldn't use the word "pedagogical" in that way, but yes. The analogy I'd draw would be to "programming by intention", where we write the code to...
Ron Jeffries
RonaldEJeffries
Offline Send Email
Oct 3, 2005
2:32 pm

Ron, ... Hmm I meant padagogy in the sense of "The act, process, or art of imparting knowledge and skill" (http://www.answers.com/topic/pedagogy). By "BDD has...
Ravi Mohan
magesmail
Offline Send Email
Oct 3, 2005
2:57 pm

... Well I think that "pedagogy" means the imparting of X from one person to another, and that it may not properly apply to rituals or practices that one does...
Ron Jeffries
RonaldEJeffries
Offline Send Email
Oct 4, 2005
2:28 pm
 First  |  |  Last 
Advanced

Copyright © 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help