在 Rails 中,我应该在水豚(或集成)测试中包含用户输入表单错误流吗?

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

Rails 支持多种类型的测试:

而且,有了水豚,它还可以支持:

在一些网站上,我看到这些 acceptance/integration/feature 测试应该只测试特定的流程,为其他类型的测试留出边缘情况。例如:

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://guides.rubyonrails.org/testing.html#integration-testing

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://robots.thoughtbot.com/how-we-test-rails-applications

但我也看到了类似的东西:

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!

https://www.learnhowtoprogram.com/lessons/integration-testing-with-capybara

所以,这就是我的问题:在 Rails 中,我应该在水豚(或集成)测试中包含用户输入表单错误流吗?

或者您认为编写视图测试来测试是否存在 flash 消息、测试失败流通过控制器测试和分配助手、只有测试成功流通过 acceptance/integration/feature 测试就足够了吗?

编辑接受的答案是由于评论。

用户输入表单错误由 Active Record validations in Rails. So you could cover these with unit tests 处理。但是这些类型的测试仅验证您的模型是否存在验证。除了允许您在另一种框架或语言中重新创建模型并仍然让您的测试通过之外,我不确定这些类型的测试提供了多少实用性。