问题描述
这更多是一个一般性问题,是某种最佳实践的讨论.
This is more of a general question and some sort of best practice discussion.
一个人将如何测试Rails应用程序?
How would one test a Rails application?
有BDD和TDD之类的口头禅,还有RSpec和Cucumber之类的框架,但是多少才够,最好的方法是什么?
There are mantras like BDD and TDD and frameworks like RSpec and Cucumber but how much is enough and what is the best way to go?
使用Cucumber作为集成测试是否足够?你们也在写其他单元测试吗?
Is it enough to use Cucumber as integration tests?Are you guys writing additional unit tests, too?
那么您的Rails测试策略又是什么?
So what and how is your Rails testing strategy?
期待好的意见...
推荐答案
一个人将如何测试Rails应用程序?彻底针对百分之八十的覆盖率和不少!
How would one test a Rails application?Thoroughly, aiming for Eighty percent coverage and no less!
关于如何"的实际决定很容易,但是多少"可能很难回答.
The actual decision as to "how" is easy, but "how much" can be a difficult to answer.
我有几个小的(几乎不是很旧的项目),几乎没有测试,这些测试往往是代码中关键组件的低级单元测试.有时候,我希望他们进行更多的测试,但总的来说,它们会与很小的表面积混合在一起,从而使调试和手动测试变得非常简单.
I have a couple of small (almost but not quite legacy) projects with next to no tests, and the tests tend to be low-level unit tests of crucial components in the code. On occasion I wish they had more tests, but in general they are thrown together with quite small surface areas that make debugging and manual testing pretty straight forward.
在我的日常工作中,我们将rSpec,Cucumber和Selenium用于一个相当大的Rails项目(超过10个开发人员,正在开发中).
In my day job, we're using rSpec, Cucumber and Selenium on a fairly large Rails project (10+ developers, several years in the making).
rSpec提供了我们所有模型,控制器,帮助器和其他类的单元范围.
rSpec provides unit coverage for all our models, controllers, helpers and other classes.
Cucumber提供了更高级别的功能和集成测试.
Cucumber provides higher-level functional and integration tests.
Selenium用于通过javascript(在Capybara和Cucumber中运行)来锻炼我们UI的javascript密集区域.我们的测试和质量检查团队还使用了一套硒测试回归测试(发布到质量检查的版本已通过我们的CI版本以绿色点亮).
Selenium is used to excercise javascript-intensive areas of our UI with javascript (running through Capybara and Cucumber). We also have a suite of regression tests in Selenium used by our Test and QA team (versions released to QA are green-lit through our CI build).
这些天,我的最低限度"设置将是在关键和/或复杂区域使用rSpec进行单位级别的覆盖,并在通过应用程序的关键路径上进行全套功能Cucumber测试.
My "bare-minimum" setup these days would be unit-level coverage using rSpec on the critical and/or complex areas and a full suite of functional Cucumber tests on the critical paths through the application.
这篇关于使用Rails进行应用测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!