开始对 Rails 中的现有代码库进行单元测试?

发布于 2024-10-17 09:27:34 字数 444 浏览 4 评论 0原文

大家好,

我在一家公司开始了一个新角色,正在开发一个内部用于特定管理应用程序的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花海 2024-10-24 09:27:34

自 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,

  • Write tests
  • Upgrade the component
  • Run Tests ( mostly they'll fail / possibilities of errors )
  • Make them pass
  • Refactor ( May be the new features at your disposal )

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 :).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文