在 Rails 应用程序中运行 rake 任务后出现加载消息和测试结果

发布于 2024-08-07 06:40:48 字数 599 浏览 3 评论 0原文

运行一些 rake 任务后会出现以下输出:

Loaded suite /usr/bin/rake
Started

Finished in 0.00042 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

对于与测试无关的任务,此输出没有用或没有必要。我想阻止它出现。我认为它源于需要某个文件或包含某个模块。

更新:看来我错了,在 Rails 内置的一些任务中确实出现了这种情况。这是使用 --trace 加载的装置的输出。

$ rake db:fixtures:load --trace

** Invoke db:fixtures:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:fixtures:load
Loaded suite /usr/bin/rake
Started

Finished in 0.000255 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

The following output appears after running some rake tasks:

Loaded suite /usr/bin/rake
Started

Finished in 0.00042 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

This output is not useful or necessary for tasks not related to testing. I'd like to prevent it from appearing. I would assume it stems from requiring a certain file or including a certain module.

Updated: It appears that I was wrong and this does come up during some of the tasks built into Rails. Here is the output of fixtures being loaded with --trace.

$ rake db:fixtures:load --trace

** Invoke db:fixtures:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:fixtures:load
Loaded suite /usr/bin/rake
Started

Finished in 0.000255 seconds.

0 tests, 0 assertions, 0 failures, 0 errors

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浊酒尽余欢 2024-08-14 06:40:48

解决方案可以在这里找到:

http://github.com/thoughtbot/shoulda/issues /#issue/59

基本上不需要 shoulda gem,除非它是测试环境(其中已经需要 test/unit)。

Solution can be found here:

http://github.com/thoughtbot/shoulda/issues/#issue/59

Basically don't require the shoulda gem unless it's the test environment (where test/unit would already be required).

小嗲 2024-08-14 06:40:48

首先检查 Rake::TestTask 的测试模式。应该类似于 'test/**/*_test.rb'

无论出于何种原因,Test::Unit 都会尝试在 /usr/bin/rake 可执行文件中查找测试,这可能意味着您在某处有一个伪造的模式。

每当遇到此类问题时,您都需要使用 --trace 运行 rake 来查看正在运行哪些任务和任务依赖项以及运行顺序。如果更新模式不起作用,请将打开 --trace 的完整运行的输出复制到您的问题中。

First check the test pattern for your Rake::TestTask. Should be something like 'test/**/*_test.rb'.

For whatever reason, Test::Unit is trying to find tests in the /usr/bin/rake executable, which probably means you've got a bogus pattern somewhere.

Anytime you have problems like this, you want to run rake with --trace to see what tasks and task dependencies are being run, and in which order. If updating the pattern doesn't work, please copy the output of a full run with --trace switched on into your question.

罪歌 2024-08-14 06:40:48

我找到了这个文件: ~/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/minitest/unit.rb

在第 498 行(就在“def self.autorun”之后)我把:

return # the user of this computer put this here, because of reasons

我不认为这个方法会让我觉得想念他......

I got to this file: ~/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/minitest/unit.rb

And at line 498 (just after "def self.autorun") I put:

return # the user of this computer put this here, because of reasons

I don't think this method will make me fell as missing him...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文