[英]Rails 7 - Difference between "Rails test" and "bundle exec rake test"
I'm starting a new Rails 7 app and have about 150 tests on Minitest.我正在启动一个新的 Rails 7 应用程序,并在 Minitest 上进行了大约 150 次测试。
I've seen in some places people using in the terminal of command rails test
and other places recommending bundle exec rake test
我在某些地方看到人们在 command
rails test
的终端中使用,而其他地方则推荐使用bundle exec rake test
I have some basic tests and when I run both commands in my terminal, the same exact things appear and I have the same amount of tests with the same test results.我有一些基本测试,当我在终端中运行这两个命令时,会出现完全相同的东西,并且我有相同数量的测试和相同的测试结果。
So I'm wondering if there is any difference between the two on Rails 7?所以我想知道 Rails 7 上的两者有什么区别吗?
The difference between those commands is from where rails is called.这些命令之间的区别在于调用 rails 的位置。
Running commands with bundler allows you to execute them without having the packages installed in your system.使用 bundler 运行命令允许您在系统中不安装软件包的情况下执行它们。
For example, if you don't have rails installed globally you couldn't run commands using rails directly例如,如果您没有全局安装 rails,则无法直接使用 rails 运行命令
rails test
will raise the following error: rails test
将引发以下错误:
Rails is not currently installed on this system.
Rails 目前没有安装在这个系统上。 To get the latest version, simply type:
要获取最新版本,只需键入:
$ sudo gem install rails
$ sudo gem 安装导轨
You can then rerun your "rails" command.
然后,您可以重新运行“rails”命令。
But if you run bundle exec rails test
instead you should run your test suite perfectly because you're calling rails through bundle.但是如果你运行
bundle exec rails test
,你应该完美地运行你的测试套件,因为你是通过 bundle 调用 rails 的。
In your case using bundle exec rake test
will ensure that you're using the same version of your Gemfile.lock
.在您的情况下,使用
bundle exec rake test
将确保您使用相同版本的Gemfile.lock
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.