tl;dr
- minitest 5.10.1 を 5.14.1 に更新したら直った
- ref: https://github.com/connorshea/vscode-ruby-test-adapter/issues/20#issuecomment-668046280
環境
- 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.
結論
- https://github.com/connorshea/vscode-ruby-test-adapter/issues/20#issuecomment-668046280 のとおり 5.14.1 に上げたら直りました
- Gemfile に 書いて bundle install です。
Gemfile
gem 'minitest', '5.14.1'