I'm just starting to practice BDD using the GWT approach to the following code exert and just realised that I can't do the second test.
My GWT goes something like
Given there exists an open query
When the user replies to the query
Then it should save the reply if the reply is not blank
Then it should notify the user and not save the reply if it is blank
So I coded it up like so
public class when_user_replies_to_the_query : OpenQuery
{
Because
{
query.Reply(data);
}
ThenIt should_save_the_reply_to_the_database_if_there_is_a_reply
ThenIt should_notify_the_user_if_there_is_no_text_in_the_reply_and_not_save_to_database
}
public class Query
{
void Reply(string data)
{
//do something
}
}
But then I realised that I can't do the second case because the first case requires data to have something in it whilst the second case says that data should be an empty string.
Does this mean that I should be splitting my GWT into something like
Given the reply is blank
When the user replies to the query
Then it should notify the user ......
If this is the case, then I'd be writing a huge amount of null case scenarios for return
values being null. Such as
Given the database is null
When retrieving queries
Should reply with error message
When saving queries
Should save to file and reply with error message
When // basically doing anything
Should //give appropriate response
Is this how I should be writing my BDD specs? And am I even in the right forum O_O?