By Alex Yakyma
There's a couple of good ATDD tools already on the market and all of those are free ones but it doesn't come all free eventually. Certainly there's learning curve for each. And even more so, there's real danger that the team may not necessarily adopt them which may influence badly the adoption of ATDD itself.
There's a surprising news for teams though: if they are using JUnit (or actually almost any unit testing framework from the xUnit family) - it can be used for ATDD very efficiently.
Let me show this on an extremely simplistic example. We're building simple Calculator service, that's the brief context.
First, let's specify our examples of system behavior that will serve us also as specification of the acceptance tests.
Adding 2 and 3 is 5
Adding 0 and -1 is -1
Multiplying 3 by 6 is 18
Multiplying 4 by 0 is 0
Multiplying -1 by 16 is -16
Multiplying 7 by 1 is 7
...it's very straightforward, isn't it?
Now what we do is implement the test (using JUnit):
Notice that for all these tests there's no an important nuance that many developers would miss while working on their unit tests:
Each assertion now includes the message and the message is exactly the specification.
This basically performs one of the key roles of ATDD - sustaining a living documentation and traceability to code. Now, if something fails, you know what exactly that is:
As we can see, now JUnit tells us what exactly goes wrong with the code, or better say - what exactly it fails performing at this moment of time.
Very simple!.. And if your team already uses JUnit then there's no additional effort to master a new tool, so you can concentrate on the technique itself.
This reminds me to mention in the end that tooling really secondary to ATDD, what is first and foremost is to ensure that those examples that the team is automating and then implementing come from the the people in the company who actually know what their client wants.