14 February 2010
Combining TDD/BDD with DDD
Its not unnatural to think that the prototypical xDD combinations (TDD, BDD, DDD, and friends) are somehow in competition with each other. If you are unsure of their exact meanings, why wouldn’t you believe that TDD is in opposition to BDD and DDD? I mean, they all mean “Hmmhmm Driven Design/Development”. How many things can really drive design or development at the same time?
But, luckily, this turns out to be a misconception. At least in this case: Domain-driven design (DDD) can be very well applied together with Test-driven development or Behaviour-driven development. This post describes one way you might think about this. You may find a much better way for your situation.
Read the rest of this entry »
8 February 2010
xDD: An Overview
I don’t know if it’s more comical or tragical to see all those xDD combinations that exist in software development. By “xDD” I mean any one of TDD, BDD, DDD, RDD, FDD, etcetera. Software developers often make fun of this our tendency to suffix everything with “DD”. I have three points to make about this:
- People get confused. They have a hard time understanding and keeping up with all the buzzwords that float around, especially if they are similar. There is some risk that they’ll simply discard all of them, even though some xDDs are truly invaluable techniques for a professional developer.
- Even if someone thinks that one of the xDDs would be useful she may, falsely, believe that the xDDs are mutually exclusive. Some of them are, some are not, some are in-between.
- This is a power-struggle, in some sense. The whole issue revolves around what should drive software development, i.e. what should be the most important thing. That’s a pretty big issue. What if you could go down in history as the person who understood software development so well that you found the magic key to unlock the whole field? Mind-boggling. (For the record, I don’t think there is one.)
This first post focuses on the first point; what these xDDs are. I have selected three of the most popular ones today, which I know pretty well, and tried to describe them concisely. I’ll also mention a few other xDDs as well.
4 February 2009
TDD/BDD-kursen är tillbaka
Jag och min kurskollega Måns har arbetat hårt under hösten med att vidareutveckla vår kurs i TDD/BDD. Vi har redan tidigare kört kursen en handfull gånger och fått mycket goda vitsord, men världen förändras och även vi. En nyhet är att vi delat upp kursen i flera kurser som riktar sig till personer på olika nivå. Vi har en kurs för nybörjare, en för erfarna och en för experter. En annan nyhet är att vi satsat hårt på att förbättra vår didaktik, hur vi får personer att lära sig ämnet. Vi har också utökat tiden för praktik, för det går inte att lära sig TDD utan att göra det själv.
Om du eller någon du känner är intresserad så kan jag tipsa om att kursen för nybörjare kommer att ges publikt igen, 9-10 mars i Stockholm, i arrangemang av Jaybis. Den här kursen är lämplig både om man är helt ny på området eller om man är erfaren på enhetstestning men inte på TDD. Vi kör i javamiljö, men det är inte viktigt, vi har haft många dotnetutvecklare som har gått kursen utan problem. På två dagar går det inte att bli expert på TDD, men vi siktar på att ge deltagarna en god start på sin TDD-bana.
Permalink Comments off
19 September 2008
Hints for getting JBehave2 up and running
I started fiddling a bit with the new JBehave2 yesterday. It looks quite a bit like RSpec for Java, which sounds great on paper. Since I have a long history with Fitnesse I would be interested to try another approach.
To get started with JBehave, me and my pair programming partner Måns decided to try and get the example from the JBehave home page to work. We had 30 minutes to do it. Three classes and a one text file. We should be able to do it! We failed (of course).
Back home I took a second look at the problem and managed to get a first example working (not exactly the one from the JBehave home page, but more of a Hello World example). It was a bit tricky though so I thought I would share some experiences.
This my (pathetic) little scenario:
Given I have a greeting system
When I give my name as Måns
Then I should see a greeting, “Hello, Måns!”
Here are some hints to get your first example working:
- Don’t put your code in the default package. We did this. But putting your code into the default package leads to spurious NullPointerException on line 36 of the UnderscoredCamelCaseResolver. (This line looks a little train wreckish, which is ironic in a BDD package.)
String packageDir = scenarioClass.getPackage().getName().replaceAll(DOT_REGEX, SLASH);
- Quotes in the test definition must be escaped by a backslash in the Java annotation to actually work. In the sample scenario text file a message is surrounded by double quotes. The sample code on the start page will not work but \”$message\” will.
- It is mentioned on the JBehave home page, but worth repeating, that some versions of Eclipse (my version of Ganymede at least) cannot run the JBehave scenario out of the box. The reason for this is apperently that the JUnit runner cannot find the @Test annotation inside the JBehave core jar. (This sounds like a bug in Eclipse to me.) To fix it now you need to download and attach the source code for JBehave core to the JAR file. This is done in the project properties Java Build Path editor. Open the jar and indicate to Eclipse the location of the source archive. Now Eclipse should see the @Test annotation and you can run the scenario.
- The example code mentions a “matcher” method called containsMessage. Matchers are used to create specifications and assertions. This is probably a typo, why would there be a general matcher method with that name? Or maybe I have misunderstood? However, the Hamcrest matchers do contain a matcher method called containsString, which sounds a bit more plausible. Change the name.
- To get the containsString matcher working I had to download the hamcrest-all-1.1.jar and put it on the class path. I believe that the Hamcrest core matchers are part of JUnit 4.4+ but the containsString matcher is part of the hamcrest text matchers. Make a static import of org.hamcrest.Matchers.* to access all matchers.
For non-english speakers you will be happy to know that characters outside the ASCII set works. Now I need to find a way to translate the keywords “Given”, “When” and “Then” to Swedish to get a full Swedish example working. Good luck!