简体   繁体   中英

How to add TestUnit / Minitest to rails 4

So I did a:

--skip-test-unit

When installing rails 4, and now I want to use testunit / minitest (not sure which one is default in rails 4.1?)

So how do I re-add testunit / minitest to rails?

There is no default rake command for this but the simplest workaround is generate new rails application with test

rails new test1

now copy the test folder from test1 to your repository

cp -r test ../your_repository_name

open config/application.rb

uncomment require "rails/test_unit/railtie"

now when you will generate model or controller in you application, then it will generate test files also.

For previous model and controller you can use

rails generate test_unit:controller ControllerName
rails generate test_unit:model ModelName

By default Rails 4.1 is using minitest (5.3.3)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM