Cucumber/Rspec:有没有办法从现有代码中提取测试?

发布于 2024-10-04 08:10:01 字数 295 浏览 0 评论 0原文

我要开始学习 cucumber/rspec。

我在rails3/mysql和rails3/mongoid中没有任何应用程序,我在没有任何测试的情况下编写了:-(

应该想知道我是否可以有一个“cucumber/rspec”生成器,它可以提取黄瓜的场景和“步骤定义”,就像rspec 的行为。一种逆向工程代码生成器,它从现有控制器/模型/视图中提取测试。

是否建议使用其他方法将旧的错误代码与未来的良好实践测试相结合?

您 之外/内部,但是,如何清理数千行旧代码?

在 BDD开发 卢卡·G·索阿夫

I'm going to begin learning cucumber/rspec.

I've few application in rails3/mysql and rails3/mongoid which I wrote without any test :-(

Should be wonder if I could have a "cucumber/rspec" generator which could extract scenario and "step definition" for cucumber, just like behaviors for rspec. A kind of reverse engineering code generator, which extract tests from existing controllers/models/views.

Do you suggest any other approach for having old buggy code alligned to the future well practice testing ?

I know this completely broke the vantage of outside/in BDD development but, how to sanitize thousand of lines of old code ?

Thanks in advance
Luca G. Soave

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

去了角落 2024-10-11 08:10:01

如果测试可以自动生成,我们一开始就不需要它们,不是吗?

以下是在时间有限时处理未经测试的遗留应用程序的方法:

  • 为应用程序中 3 个最重要的故事编写 Cucumber 场景。例如,如果您的应用程序是购物系统,则这将是:浏览文章、将商品添加到购物车、结账。
  • 当您添加新功能时,请进行测试驱动。
  • 当您更改未经测试的代码时,请为您正在接触的代码添加测试。
  • 当您修复错误时,请为您正在修复的代码添加测试。

一段时间后,您将为您的应用程序提供足够好的测试覆盖率。

祝你好运。

If tests could be auto-generated, we wouldn't need them in the first place, would we?

Here's how to deal with untested legacy application when your time is limited:

  • Write Cucumber scenarios for the 3 most important stories in your application. E.g. if you're application is a shopping system this would be: browse articles, add item to cart, checkout.
  • When you're adding new features, do it test-driven.
  • When you're changing untested code, add a test for the code you're touching.
  • When you're fixing a bug, add a test for the code you're fixing.

After a while you will have nice enough test coverage for your application.

Good luck.

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