BDD : A Change in thinking part II
Hi!
Ok, following on from the last post, lets examine whats going on here. We have one main “outer” class called Login_Specification. Now my convention (based on work from jp and mspec) is to add an _Specification to the class name. To me, this provides a central location for all the scenarios for a login specification.
Next we have the “when_the_user_logs_in” class. This is the actual story. So in this case its the story that specifys the behaviour of “the user logging in”. This inherits from Story_For<> which is a generic base class that provides some syntax sugar, bringing bdd and the AAA style closer (more on this class later).
Next we have the “if_the_credentials_supplied_are_correct” class this inherits the “story” class above. This is the actual scenario. In the traditional unit testing world this would be your TestClass. This is where the “should” will created. So as an example, if the story + 1st scenario was …
“If the credentials supplied are correct when the user logs in, it should show the home page.”
public void it_should_direct_the_user_to_the_home_page () {
// this is where the ‘assertions’ happen..
}
This gives us executable code that
-
matches our user story.
-
can be run many times over to verify we are still “meeting the spec”
-
can be automated
Hope this help!
Thanx