我刚刚开始练习使用GWT方法对下面的代码施加BDD,并且意识到我不能做第二次测试。如何使用MSpec与GWT BDD?写这个场景的正确方法
我的GWT去像
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
那么就应该通知用户,而不是保存回应,如果它是空白
所以我编写它像这样
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
}
}
但那么我意识到我不能做第二种情况,因为第一种情况要求数据有内容,而第二种情况说数据应该是空字符串。
这是否意味着我应该分割我的GWT成类似
Given the reply is blank
When the user replies to the query
Then it should notify the user ......
如果是这样的话,那么我会写一个巨大的空案例场景金额回报
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
这是我应该如何写我的BDD规格?我甚至在正确的论坛O_O?