ruby-on-rails – 为现有应用程序编写测试用例(Rspec)

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 为现有应用程序编写测试用例(Rspec)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
作为Rspec noob,我不知道这个问题是有道理的.我真的很困惑,无法得到解决方案.

We have one new requirement,asked us to write Rspec test cases for existing project. They have application with rails3 that already working but they want rspec cases to be written now

我的问题是

Writing Rspec cases for existing application does make sense?

Can we write spec for already working project

Should we follow any guidelines to write specs for already written app

谢谢

解决方法

正如dpassage正确指出的那样,你的问题与rspec无关.这是关于遗留代码的单元测试.

Writing Rspec cases for existing application does make sense?
Can we write spec for already working project

是.在编写应用程序之前首先编写测试时最好.写测试永远不会太晚,起步晚不伤人.
测试遗留代码Adding unit tests to legacy code

Should we follow any guidelines to write specs for already written app

我的两分钱:

>逐步添加测试
>首先测试应用程序中最重要的部分.即首先开始编写单元测试并关注重要模型(而不是所有模型).测试模型后,请转到功能测试(控制器)和集成测试.记住:要吃大象,我们需要一次吃一块.
>如果现有模型难以编写测试,则意味着您需要重构代码.重构使您的模型易于测试.
>始终从现在开始为新模型/实施编写单元测试.

有用的参考:

>以TDD为例 – Kent beck book
>有效测试:http://www.confreaks.com/videos/917-railsconf2012-testing-best-practices-or-the-five-habits-of-highly-effective-tests

原文链接:https://www.f2er.com/ruby/267431.html

猜你在找的Ruby相关文章