0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

vscode の Ruby Test Explorer で minitest を動かすと NoMethodError: undefined method `klass' for ...

Last updated at Posted at 2021-01-20

tl;dr

環境

  • VS Code Version: 1.52.1
  • ruby 2.6.3 (rbenv)
  • minitest (5.10.1)

はじめに

  • 以下のようなサンプルの test を書く
test/test_import.rb
require 'minitest/unit'
require 'minitest/autorun'


class TestFoo < MiniTest::Test
  def setup
  end

  def test_foo
    assert_equal 1, 1
  end
end
  • vscode + Ruby Test Explorer で試すと実行してるようだが、処理中のままになる

  • Settings で Ruby Test Explorer: Logpanel を True にし Ruby Test Explorer Log の OUTPUT を確認すると以下の通り

[2021-01-20 09:38:33.897] [INFO] Running command: bundle exec rake -R $EXT_DIR vscode:minitest:run 'test/test_import.rb:9'
[2021-01-20 09:38:34.562] [DEBUG] [CHILD PROCESS OUTPUT] 
[2021-01-20 09:38:34.562] [DEBUG] [CHILD PROCESS OUTPUT] RUNNING: ./test/test_import.rb[9]
[2021-01-20 09:38:34.563] [DEBUG] [CHILD PROCESS OUTPUT] rake aborted!
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] NoMethodError: undefined method `klass' for #<TestFoo:0x00007fa8ad1c15f8>
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] Did you mean?  class
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode/minitest/reporter.rb:66:in `vscode_result'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode/minitest/reporter.rb:27:in `record'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode/minitest/runner.rb:40:in `block in run'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode/minitest/runner.rb:39:in `each'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode/minitest/runner.rb:39:in `run'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode/minitest.rb:36:in `run'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.vscode/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/ruby/vscode.rake:14:in `block (3 levels) in <top (required)>'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.anyenv/envs/rbenv/versions/2.6.3/bin/bundle:23:in `load'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] /Users/murasawa/.anyenv/envs/rbenv/versions/2.6.3/bin/bundle:23:in `<main>'
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] Tasks: TOP => vscode:minitest:run
[2021-01-20 09:38:34.564] [DEBUG] [CHILD PROCESS OUTPUT] (See full trace by running task with --trace)
[2021-01-20 09:38:34.570] [INFO] Child process has exited. Sending test run finish event.

結論

Gemfile
 gem 'minitest', '5.14.1'
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?