Behavior-driven development (BDD)
Behavior-driven development (BDD) is an extension of test-driven development (TDD): development that makes use of a simple, domain-specific scripting language.
Method names
Test method names should be sentences. You should read tests like this:
Naming template
A simple sentence template keeps test methods focused. There is a convention of starting test method names with the word “should ”. The class should do something – means you can only define a test for the current class. This keeps you focused. If you find yourself writing a test whose name doesn’t fit this template, it suggests the behavior may belong elsewhere.
“Behaviour” is a more useful word than “test”
That’s not to say that testing isn’t intrinsic to TDD – the resulting set of methods is an effective way of ensuring your code works. However, if the methods do not comprehensively describe the behaviour of your system, then they are lulling you into a false sense of security.
Requirements are behaviour, too.
Ubiquitous language
Scenario is the template that is loose enough that it wouldn’t feel artificial or constraining to analysts but structured enough that we could break the story into its constituent fragments and automate them.
Given some initial context (the givens), When an event occurs, Then ensure some outcomes.
Example:
Acceptance criteria should be executable
The fragments of the scenario – the givens, event, and outcomes – are fine-grained enough to be represented directly in code.
For C# you can use SpecFlow (provides a syntax which allow non-programmers to define the behaviors which developers can then translate into automated tests):
Last updated