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
谢谢
解决方法
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