testingautomated-testsspecflowuser-acceptance-testing

Is it important to have an automated acceptance tests to test whether a field saves to a database?


I'm using SpecFlow for the automated Acceptance Testing framework and NHibernate for persistance. Many of the UI pages for an intranet application that I'm working on are basic data entry pages. Obviously adding a field to one of these pages is considered a "feature", but I can't think of any scenarios for this feature other than

Given that I enter data X for field Y on Record 1 
And I click Save 
When I edit Record 1 
Then I should data X for field Y

How common and necessary is it to automate tests like this? Additionally, I'm using NHibernate so it's not like I'm handrolling my own data persistance layer. Once I add a property to my mapping file, there is a high chance that it won't get deleted by mistake. When considering this, isn't a "one-time" manual test enough? I'm eager to hear your suggestions and experience in this matter.


Solution

  • I usually have scenarios like "successful creation of ..." that tests the success case (you fill-in all required fields, all input is valid, you confirm, and finally it is really saved). I don't think that you can easily define a separate scenario for one single field, because usually the scenario of successful creation requires several other criteria to be met "at the same time" (e.g. all required fields must be filled).

    For example:

    Scenario: Successful creation of a customer
    Given I am on the customer creation page
    When I enter the following customer details
    | Name | Address |
    | Cust | My addr |
    And I save the customer details
    Then I have a new customer saved with the following details
    | Name | Address |
    | Cust | My addr |
    

    Later I can add additional fields to this scenario (e.g. the billing address):

    Scenario: Successful creation of a customer
    Given I am on the customer creation page
    When I enter the following customer details
    | Name | Address | Billing address |
    | Cust | My addr | Bill me here    |
    And I save the customer details
    Then I have a new customer saved with the following details
    | Name | Address | Billing address |
    | Cust | My addr | Bill me here    |
    

    Of course there can be more scenarios related to the new field (e.g. validations, etc), that you have to define or extend.

    I think if you take this approach you can avoid having a lot of "trivial" scenarios. And I can argue that this is the success case of the "create customer feature", which deserves a single test at least.