//given //when //then forever

public void shouldDoSomethingCool() throws Exception {


I like to call it the Ultimate Test Template. I’m so fond of those 3 little comments but surprisingly, I didn’t buy it at first. Micheal (it’s you, tapestry-maven-iPhone fan boy =), friend from ThoughtWorks showed me it a couple of years ago. Actually, he didn’t show it to me – I just overheard him coaching a young dev about it. That day I thought I didn’t need any hip comments because my tests were great anyway. It was foolish.

Don’t be a fool like me and start writing //given //when //then today. Life is too short for messing around – you want to get level 85 in software craftsmanship soon, right? Here’s the deal: use the template for 1 iteration and if you don’t like the results then I will give you your money back. Seriously, no matter what you think about it – buy it! BTW. If you need to document some ‘exceptional’ behavior in your test somewhere there is the template for tests with exceptions.

Lately, I’ve been selling //given //when //then quite relentlessly. I even try to sell it via Mockito api. (The link also shows how to install the template in Eclipse so don’t miss it!)

I tried to lobby for the Church of given-when-then in Krakow, Warsaw & Kiev. I heard rumors that Wroclaw develops a growing number of brothers and sisters in faith =)

I think I forgot to thank Dan North for given-when-then and Liz Keogh for the idea of BDD aliases in Mockito. There you go!

63 Responses to //given //when //then forever

  1. I used to do the same thing in JUnit. Then I created Spock (http://spockframework.org), which supports given/when/then natively and gives actual meaning to these terms. :-)

  2. szczepiq says:

    You showed me spock at devoxx ’08 as far as I remember =)

    From the unit testing tools I’ve came across so far I must say spock has the coolest API. It is a total beauty. Well done!!!

  3. msuarz says:

    Hi Szczepan

    I have my own mock framework (C#) http://fluentspec.com … it’s quite unusual and allows to write Given/When/Then in the test … nobody uses it but you might find something interesting about it

    keep up the good stuff

  4. szczepiq says:

    wow, fluentspec looks quite interesting – I’ll get back if I have any sensible feedback =)

  5. Daniel Siwiec says:

    A nice debate on gwt style can be found here:

  6. padcom13 says:

    I personaly prefer the arrange/act/assert schema but it boils down only to the names. The actual content of the sections is the same.

  7. […] in your tests, mockito has aliases in BDDMockito so that your actions can clearly follow the given/then/when […]

  8. […] is my preferred way of documenting ‘exceptional’ behavior. There you go, it is The Ultimate Test Template for ‘exceptional’ […]

  9. […] przez Pawła i sama idea jakoś nie bardzo mi podchodzi. Chyba pozostanę przy zwykłych testach z given, when, then. Jeśli ktoś natomiast BDD (Behavior Driven Development)  się interesuje to polecam przejrzeć […]

  10. Hello! Quick question that’s completely off topic. Do you know how to make your site mobile friendly? My site looks weird when viewing from my iphone. I’m trying to find a template or plugin that might be able to resolve this
    problem. If you have any suggestions, please share.
    Many thanks!

  11. Nichol says:

    Yes! Finally someone writes about baltimore tours.

  12. cho thue nha says:

    After going over a number of the blog posts on your web page, I
    really appreciate your way of blogging. I saved it to my
    bookmark site list and will be checking back in the near future.
    Please check out my web site as well and tell me your opinion.

  13. W naszej ofercie znajdziecie Państwo profesjonalne folie wszelkiego typu
    i rodzaju. Polecamy zwłaszcza folię budowlaną, którą oferujemy w ogromnie atrakcyjnych cenach.

    Proponowana przez nas folia budowlana jest jedną z najlepszych na rynku, a co
    najważniejsze, wyróżnia ją naprawdę wyjątkowa cena.
    Dlatego promujemy ten produkt. Warto również dodać,
    że nasza folia budowlana ma gwarancję jakości, dzięki temu jest zakupem
    ewidentnie bardziej opłacalnym. Wyjątkowo duża odporność
    i skuteczność to jej najważniejsze zalety.

  14. Vivien says:

    I relish, cause I discovered just what I used to be looking for.
    You have ended my 4 day lengthy hunt! God Bless you man.
    Have a nice day. Bye

  15. Uta says:

    This design is incredible! You most certainly know
    how to keep a reader entertained. Between your wit and your videos, I was
    almost moved to start my own blog (well, almost…HaHa!) Wonderful job.
    I really loved what you had to say, and more than that, how you presented it.
    Too cool!

  16. szukam zony says:

    Do you have a spam issue on this blog; I also am a blogger,
    and I was wanting to know your situation; we have developed some nice procedures and
    we are looking to exchange methods with others, why not shoot me an email if interested.

  17. I comment whenever I like a post on a website or if I have something to valuable to
    contribute to the conversation. Usually it is a result of the passion communicated
    in the article I read. And on this post //given //when //then
    forever | monkey island. I was actually moved enough to post a thought :-P I do have a couple of questions for you if you do not mind.
    Is it just me or do some of these responses appear like written by brain dead individuals?
    :-P And, if you are posting on other sites, I
    would like to keep up with you. Could you list every one of all your shared
    sites like your linkedin profile, Facebook page or twitter feed?

  18. Smh says:

    Yeah, that’s the tiktce, sir or ma’am

  19. Dedi says:

    I litlarely jumped out of my chair and danced after reading this!

  20. sex oferty says:

    I usually do not drop a leave a response, but I read a few of the comments on //given //when //then forever | monkey island.
    I do have a couple of questions for you if it’s allright. Is it simply me or does it look like like some of the comments appear like they are left by brain dead individuals? :-P And, if you are posting on other social sites, I’d
    like to keep up with anything fresh you have to post. Could you post a list
    of all of all your public sites like your Facebook page, twitter feed, or linkedin profile?

  21. May I just say what a comfort to uncover someone who truly
    understands what they’re discussing over the internet. You actually understand how
    to bring a problem to light and make it important.
    More and more people ought to look at this
    and understand this side of the story. I was surprised you are not more popular because you certainly possess the gift.

  22. Hi, just wanted to tell you, I enjoyed this article. It was practical.

    Keep on posting!

  23. Indahlestari says:

    Tip top stfuf. I’ll expect more now.

  24. Sweet blog! I found it while searching on Yahoo News.
    Do you have any suggestions on how to get listed in Yahoo News?
    I’ve been trying for a while but I never seem to get
    there! Thank you

  25. It’s very simple to find out any matter on net as compared to books, as I found this post at this site.

  26. I’m not that much of a internet reader to be
    honest but your sites really nice, keep it up!
    I’ll go ahead and bookmark your website to come back later on.

  27. Warsaw Shore: Ekipa camaro z Warszawy , process typu inescapable
    fact reveal
    bazujący kod nas formacie Ekipa camaro Nj-new jersey, produkowany as i emitowany
    poprzez MTV Polska. Jego premiera odbyła się
    w listopada 2013 roku instances Warsaw Shore 2 sezon odcinek 5 online, ekipa z warszawy
    sezon 2 odcinek 5 godzinie 5: 00. Od 22 Maja 2014 roku process jest emitowany również w Danii,

    Szwecji, Niemczech, Szwajcarii, Finlandii, Belgii, Holandii,
    Norwegii oraz Warsaw Shore 2 sezon odcinek 5 online, ekipa z warszawy sezon 2 odcinek 5rejonach Flandrii.
    Warsaw Shore osiągnął najwyższe wyniki oglądalności MTV Polska
    od czasu powstania stacji. eight lutego 2014 roku MTV Polska ogłosiła, że wiosną Warsaw Shore 2 sezon odcinek 5 online,
    ekipa z warszawy sezon 2 odcinek 52014 roku wyemitowana zostanie druga podria ser programu.
    Zaplanowano również
    wybranie nowych uczestników programu
    warsaw shore online, warsaw shore sezon 2
    online, warsaw shore sezon 2 odcinek 5 online, warsaw shore odcinek 5 online, warsaw shore livestream, warsaw shore download, warsaw shore
    poberz, ekipa z warszawy online, ekipa z warszawy sezon 2 online,
    ekipa z warszawy sezon 2 odcinek 5 online, ekipa z warszawy odcinek 5 online, warsaw shore oscinek 5 pobierz, warsaw shore odcinek 5 download

  28. Nadzwyczaj odlotowy post, interesujące zapisy zalecam wszystkim literaturę

  29. paintball says:

    Treść pokrewna każdemu, polecam literaturę

  30. An impressive share! I have just forwarded this onto a friend who was
    conducting a little homework on this. And he actually bought me dinner
    simply because I stumbled upon it for him… lol.
    So allow me to reword this…. Thank YOU for the meal!!

    But yeah, thanx for spending some time to discuss this subject
    here on your web site.

  31. Stephanie says:

    Her words were written to be read aloud, and
    have a precise, on-point rhythm that is adept and soulful.
    “That’s it I guess” she said after her last song, as the crowd pleaded for more.

    There are two dead now and the press, eager for a sensation, has dubbed this killer, the “zip-tie vigilante”.

  32. Thanks for your personal marvelous posting! I
    definitely enjoyed reading it, you happen to be a great author.I will ensure that I bookmark your blog and
    will often come back at some point. I want to encourage one to continue your great writing, have a nice day!

  33. Howdy! Do you know if they make any plugins to assist with
    Search Engine Optimization? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good success.

    If you know of any please share. Thank you!

  34. Metal roofing is not great for climates known for harsh winters.
    This is the reason you should look for roofing Minneapolis services.

    Roofing repair Toronto companies can also use the technology
    in detecting damages on chimneys, skylights, and gutters and downspouts.

  35. kazeo.com says:

    Hello There. I discovered your weblog the use
    of msn. This is an extremely smartly written article.
    I’ll be sure to bookmark it and come back to
    read more of your useful info. Thank you for the
    post. I’ll certainly return.

  36. All of those people whizzing by you may have superior bike skills,
    or they could be blowing themselves out for a long painful
    run of 13. If you’re popping up to stand on the pedals, what speed you may gain going uphill may be squashed
    by the wind catching more of your profile. There were those with lighter loads and
    stronger engines staying with him and ahead of him,
    and most of them were grateful that the sun rose high enough to be out of their eyes when they peered into
    that driver’s-side mirror.

  37. buy louis vuitton handbags online
    I always emailed this weblog post page to all my contacts, as
    if like to read it then my links will too.

  38. Beats By dr dre wireless headphones
    I all the time used to study piece of writing in news papers but now as I am a
    user of web therefore from now I am using net for articles,
    thanks to web.

  39. I like the helpful information you supply to your articles.
    I’ll bookmark your weblog and test again right here frequently.
    I’m quite certain I’ll learn many new stuff right
    right here! Good luck for the following!

  40. This piece of writing presents clear idea in favo of the new visitors of blogging, that in fact how to do blogging.

  41. Hi Dear, are you really visiting this web page daily, if
    so after that you will definitely take good experience.

  42. Snow blower Service & Repair Mobile Service Winter Tune Up NOW

  43. Right away I am going to do my breakfast, later than having my breakfast coming yet
    again to read more news.

  44. I couldn’t refrain from commenting. Perfectly written!

  45. Hey! Do you use Twitter? I’d like to follow you if that would be ok.
    I’m absolutely enjoying your blog and look forward to new posts.

  46. Emmanuel says:

    Ԍreat delivery. Sound arguments. Κeep սp tɦe good work.

  47. skyrock.com says:

    I know this web page offers quality based content and extra data, is there any
    other web page which gives these kinds of data in quality?

  48. Hayley says:

    darmowe gry maszynyowe hot spot darmowe gry na hot spotach

  49. Porn Movie says:

    Hello! I know this is kinda off topic but I was wondering if you knew where I could
    find a captcha plugin for my comment form? I’m using the same
    blog platform as yours and I’m having trouble finding one? Thanks a lot!

  50. win money says:

    What’s up friends, pleasant post and pleasant urging commented at this place, I am
    genuinely enjoying by these.

  51. Katherine says:

    After the generation athlete prototype match, in 2010.
    As a premier example of alleged narcissism after Van Zyl and Pistorius shook hands.
    61m, 52kg1 95m, 97kg1. London 2012 Olympics, dashed by South Africa and the one in the Paralympics just begun, the students practice each of
    the sport, category training, self-confidence, expect success, Coach,
    Team & League Baseball and the business.

  52. Lazaro says:

    My spouse and I stumbled over here from a different website and thought I might check
    things out. I like what I see so now i’m following
    you. Look forward to going over your web page repeatedly.

  53. Thanks for finally writing about >//given //when //then forever | monkey
    island <Liked it!

  54. nadruki na koszulki
    national debt
    steamboat springs
    small business health insurance

  55. When some one searches for his necessary thing, thus he/she needs to be available that
    in detail, so that thing is maintained over here.

  56. Great items from you, man. I’ve remember your stuff prior
    to and you are simply too magnificent. I actually like what
    you’ve obtained right here, certainly like what you’re saying
    and the way in which during which you are saying it. You
    are making it enjoyable and you continue to take care of to stay it wise.
    I can not wait to learn much more from you.
    This is really a great site.

  57. My spouse and I absolutely love your blog and find most of your post’s to be exactly
    what I’m looking for. Do you offer guest writers to write content in your
    case? I wouldn’t mind producing a post or elaborating on a lot of the subjects you write regarding here.
    Again, awesome website!

  58. Hey, I think your site might be having browser compatibility issues.
    When I look at your blog site in Safari, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to give you a quick heads up!

    Other then that, excellent blog!

  59. Нurrah, that’s what I was seeking for, what a data! existing hre at this
    blog, thanks admin of this web site.

  60. I like reading an article that will make men and women think.
    Also, thank you for allowing for me to comment!

%d bloggers like this: