In the last couple of weeks I had a chance to sprinkle some of JP’s syntactic sugar, all over my projects. It’s amazing how much more concise my units test have become. I’ve had a couple of issues where I was mocking out the behavior of some Win Forms controls, but for the most part it’s been an awesome experience!
I just wanted to take a moment to say Thank you JP! I am enjoying using your BDD (on steroids) extensions. If you haven’t already you need to check it out here… NOW!
Maaad, maaaad props Mr. JP!
10 public class behaves_like_save_changes_view_bound_to_presenter : concerns_for<SaveChangesView>
11 {
12 context c = () => { presenter = an<ISaveChangesPresenter>(); };
13
14 because b = () => sut.attach_to(presenter);
15
16 static protected ISaveChangesPresenter presenter;
17 }
18
19 public class when_the_save_button_is_clicked : behaves_like_save_changes_view_bound_to_presenter
20 {
21 it should_forward_the_call_to_the_presenter = () => presenter.was_told_to(x => x.save());
22
23 because b = () => EventTrigger.trigger_event<Events.ControlEvents>(
24 x => x.OnClick(new EventArgs()),
25 sut.ux_save_button
26 );
27 }
28
29 public class when_the_cancel_button_is_clicked : behaves_like_save_changes_view_bound_to_presenter
30 {
31 it should_forward_the_call_to_the_presenter = () => presenter.was_told_to(x => x.cancel());
32
33 because b = () => EventTrigger.trigger_event<Events.ControlEvents>(
34 x => x.OnClick(new EventArgs()),
35 sut.ux_cancel_button
36 );
37 }
38
39 public class when_the_do_not_save_button_is_clicked : behaves_like_save_changes_view_bound_to_presenter
40 {
41 it should_forward_the_call_to_the_presenter = () => presenter.was_told_to(x => x.dont_save());
42
43 because b = () => EventTrigger.trigger_event<Events.ControlEvents>(
44 x => x.OnClick(new EventArgs()),
45 sut.ux_do_not_save_button
46 );
47 }
Post Footer automatically generated by Add Post Footer Plugin for wordpress.

Mo,
What’s “sut”?
P.S.: If I gotta ask, then it needs to be renamed. If I follow Toyota’s “Objective of the Objective” exercise I can arrive at a clearer answer.
The issue is: you believe that “sut” is sufficient to communicate to me, who has never seen this code and who is scanning it, what the subject of the specification is.
Your concern as a coder of this test may in fact be the “system under test”. But I don’t know what that system is because as a user, I’m not in the same context when I read that code as you are.
My concern is quickly gaining knowledge. The spec as written has usability challenges in this regard.
The objective is the “sut”. Granted. What is the objective of the “sut”? The Objective of the Objective here will satisfy your needs as well as mine. If you code for yourself, you might as well keep your code on your own hard drive and not share it with others. It’s like creating a user interface flow that only you have an intimate understanding of at first glance, forcing others to decipher the intended experience.
If “sut” is an order, call it “order”. If “sut” is a dog, call it “dog”. If “sut” is a shopping cart, call it “shopping cart”.
The level of abstractness achieved is certainly laudable, but abstractness isn’t the objective that best serves humans. Productivity not only doesn’t come from abstractness, it’s often damaged by it.
Scott,
What can I say? You are right!
It’s about “solubility”, right? I suppose I got so used to staring at my own code, that I forget what it’s like to view it from another perspective.
Thanks for your fresh perspective,
Mo
I can’t get to the ” BDD (on steroids) extensions” link in your blog. (404 error)
any thoughts?
That’s probably because I put up the link to the old repo…
https://www.assembla.com/wiki/show/developwithpassion_bdd
Sorry about that!
mO