lundi 5 janvier 2015

In rails, should I include user input form error flows on capybara (or integration) tests?

Rails supports several types of tests:



  • Model tests

  • Controller tests

  • Functional tests

  • Integration tests


And, with capybara, it can also support:



  • Acceptance/integration/feature (depends on the author) tests


On some sites I see that these acceptance/integration/feature tests should only test particular flows, leaving edge cases for other kinds of tests. For example:



Integration tests are used to test the interaction among any number of controllers. They are generally used to test important work flows within your application.



http://ift.tt/1BD10LJ



While these are great for testing high level functionality, keep in mind that feature specs are slow to run. Instead of testing every possible path through your application with Capybara, leave testing edge cases up to your model, view, and controller specs.



http://ift.tt/L8ezyN


But I also see things like:



Your goal should be to write an integration test for every flow through your app: make sure every page gets visited, that every form gets submitted correctly one time and incorrectly one time, and test each flow for different types of users who may have different permissions (to make sure they can visit the pages they're allowed to, and not visit the pages they're not allowed to). You should have a lot of integration tests for your apps!



http://ift.tt/1xyOqh2


So, that's my question: In rails, should I include user input form error flows on capybara (or integration) tests?


Or do you think it should be enough to write view tests to test for the existance of flash messages, test failure flows via controller tests with the assigns helper, and only test successful flows through acceptance/integration/feature tests?


Aucun commentaire:

Enregistrer un commentaire