开始对 Rails 中的现有代码库进行单元测试?
大家好,
我在一家公司开始了一个新角色,正在开发一个内部用于特定管理应用程序的 Rails 应用程序。无论如何,没有与该系统相关的单元测试,当我构建系统时,我意识到非常需要构建单元测试,以便我可以在继续添加到此代码库时进行回归测试。
这是一个 Rails 1.2.7 应用程序,由于兼容性原因我无法迁移,但我将开始在后台将其上的组件移植到 3.0。
目前只有 Rails 所做的内置测试,我希望了解如何开始在系统中构建小型测试,特别是从哪些方面开始比较好?
该系统构建了许多单独的配置文件,因此我假设许多测试生成将从测试这些配置文件的各个方面/元素开始,然后从那里开始。
我已经研究过 cucumber 和 rspec,但只是想找到一些简单易用的东西,我可以在当前系统中慢慢构建它,并随着时间的推移建立一个测试基础。
任何见解、链接或其他内容将非常感激。
干杯!
G'day guys,
I've started a new role at a company and am working on a rails application that's used internally for particular management applications. At any rate, there are no unit tests associated with this system, and as I am building the system out I've realised there is a serious need to build unit tests so that I can have regression testing as I continue to add to this codebase.
It's a rails 1.2.7 app that I cannot migrate for reasons of compatibility, but I will be beginning to port components over it to 3.0 in the background.
There is currently only the built in tests that rails makes, and I would love some insights into how to get started with building small tests into the system and particularly at what aspects would be good to start?
This system builds a lot of individual config files, so I'm assuming a lot of the test generation would begin with testing those config files for individual aspects/elements and going from there.
I've had a look at cucumber and rspec, but just wanted to find something straightforward and easy to use that I could slowly build upon within the current system and build up a testing base over time.
Any insights, links or others would be really really appreciated.
Cheers!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
自 Rails 1.2.7 以来发生了很多变化,首先要做的事情之一肯定是正确的单元测试,但不是进行全面的单元测试攻击。攻击有问题的组件,
我通常通过编写集成测试以及集成测试中组件的功能测试和单元测试来执行上述步骤。
祝一切顺利,这不是一个简单的任务:)。
A lot has changed since Rails 1.2.7, definitely one of the first things would be to right unit tests, but instead of going an all out unit test attack.. Attack the problem component,
I usually do the above steps with writing the integration tests, and functional tests and unit tests for the components in the integration tests.
All the best, this ain't going to be a simple task :).