仅从现有模型/控制器生成测试 [英] Generate only tests from existing model / controllers

查看:30
本文介绍了仅从现有模型/控制器生成测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于别人工作的 Rails3 应用程序.出于某种原因,他们决定不为该应用程序提供测试,这让我感到沮丧.

I have a Rails3 app that is based on someone else's work. For some reason they decided not to supply the tests with the app, which I am finding frustrating.

我希望能够为所有现有控制器和模型搭建测试框架,这样我就可以在 test::unit 中自己创建测试.我不想重新创建模型或控制器,只想创建测试.

What I want to be able to do is scaffold the tests for all the existing controllers and models so I can get a head start on creating the tests myself in test::unit. I don't want to recreate the models or controllers, just create the tests.

我是 Rails 的新手,并且一直在寻找可能执行此操作的 rake 命令,但到目前为止都没有运气.任何建议/方向最受赞赏.

I am new to Rails, and have hunted about for the rake command that might do this, but all with no luck so far. Any advice / direction most appreciated.

推荐答案

我知道它有点旧,但你可以这样做:

I know it's a little old, but you can do this:

rails g scaffold Post -s

-s 使它跳过已经创建的文件.此外,如果您不使用该标志,它只会询问您是否要覆盖该文件,所以不用担心.

The -s makes it skip the files already created. Also, if you don't use the flag it just asks you if you want to override the file, so, no worries.

这篇关于仅从现有模型/控制器生成测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆