By performing acceptance testing and following BDD, do you approve database changes or what the user sees?

I accept acceptance tests with a steak in a Ruby on Rails application. Imagine that I want to test the functionality of a form.

  • It must create a user if all fields are correct.
  • You should not create a user if any of the fields is incorrect.

In the first case, the message will indicate that the user is created: "User created"

In the second case, error messages will indicate errors.

I can base my tests on the information displayed. That is, the first test passes if the correct message is displayed.

Or I can base my tests on database changes. That is, the first test passes if there is a new user in the database that contains the entered data.

Or I can argue for both conditions, the database should change, and the corresponding message should be displayed.

What is a conceptually adequate way to test this behavior against behavior-driven development?

What is the practical way to test this behavior, according to the pragmatic programmer?

+3
source share
3 answers

BDD . , . , When Then .

, , ( ) , , . , , , "", " ", .

BDD, , , , .

RSpec , , .. Cucumber, , , ( , ).

, . , BDD RSpec. ( PDF). , :

http://www.pragprog.com/titles/achbd/the-rspec-book

+3

, , .

. , , ( !)

, , , URL RESTful .

, , , . , , Then the database should contain XYZ, - :

Given that Fred Brown lives at 25 Warrington Grove, Springfield
When Fred orders a deckchair
Then the warehouse should receive an order:
    Deckchair
    Quantity: 1
    To: Fred Brown
    25 Warrington Grove
    Springfield

, , - , , .

, URL- RESTful .. - .

+4

I agree with what the user sees, to a certain point.

If there is some layer that could potentially store a value in memory so that it can be displayed on the site, as if it were in db when it was not actually written to db .. then it might be a good idea to back up your what the user sees "with some checks at the db level.

0
source

All Articles