Search code examples
bddmspec

Confusion about functional testing, BDD and TDD


I have a form where several fields have to be filled in. However, only one field is compulsory. So, I came up with the following spec:

 [Subject(typeof(CompanyHomeController))]
public class when_the_save_button_is_clicked
{
    private It should_verify_that_the_company_name_has_been_filled;

    private It should_show_some_text_next_to_the_company_field_if_it_has_not_been_filled;

    private It should_submit_all_the_details_on_the_form_if_there_are_no_errors;

    private It should_take_the_user_back_to_the_list_of_companies;
}

Now I'd like to implement this but I'm getting confused because it sounds very much like functional testing where I'd have to use something like the mvccontrib.watin dlls. Am I right that it's indeed functional testing? Have I formulated the specs "wrong" for BDD?


Solution

  • I wouldn't worry too much about the definitions just yet - there are a lot of blurred boundaries between the various forms of testing & BDD anyway.

    WRT Watin, I guess you're talking about testing via the browser? You can test via the browser or 'subcutaneously' directly on your controllers, both are valid ways of doing BDD. That choice is more down to what you're trying to test, how fast you want your tests to run, and so on.

    In terms of your specs, I can see they might be a little tricky to implement. You probably want to have different specs for valid/invalid submissions, e.g.:

    [Subject(typeof(CompanyHomeController))]
    public class company_form_submitted_with_fields_completed
    {
        It should_save_all_the_details_to_the_main_list;
    
        It should_take_the_user_back_to_the_company_list_page;
    }
    
    [Subject(typeof(CompanyHomeController))]
    public class company_form_submitted_with_some_fields_missing
    {
        It should_remain_on_the_company_edit_page;
    
        It should_warn_that_the_company_field_is_required;
    }
    

    (notice you don't need the 'private' modifiers, which cleans it up a bit).