Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Got deprecation message for Minitest::Test but minitest has no test method #20

Open
mishina2228 opened this issue Feb 1, 2022 · 4 comments · May be fixed by #21
Open

Got deprecation message for Minitest::Test but minitest has no test method #20

mishina2228 opened this issue Feb 1, 2022 · 4 comments · May be fixed by #21

Comments

@mishina2228
Copy link
Contributor

mishina2228 commented Feb 1, 2022

require 'minitest/autorun'
require 'test_declarative'

class MyTestUnit < MiniTest::Test
  test "your test description" do
    assert true
  end
end
$ ruby mytest_mini.rb
test_declarative is deprecated for Minitest::Unit::TestCase
test_declarative is deprecated for Minitest::Test
Run options: --seed 48646

# Running:

.

Finished in 0.005164s, 193.6620 runs/s, 193.6620 assertions/s.
1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

If require 'test_declarative' is commented out here:

$ ruby mytest_mini.rb
mytest_mini.rb:5:in `test': unknown command 'y' (ArgumentError)
        from mytest_mini.rb:5:in `<class:MyTestUnit>'
        from mytest_mini.rb:4:in `<main>'

I think it is because we have defined test method in Module first.

targets = [Module]
targets << Test::Unit::TestCase if defined?(Test::Unit::TestCase)
targets << MiniTest::Unit::TestCase if defined?(MiniTest::Unit::TestCase)
targets << Minitest::Test if defined?(Minitest::Test)

The following are used.

  • minitest (5.15.0)
  • test_declarative (0.0.6)
@mishina2228 mishina2228 linked a pull request Feb 5, 2022 that will close this issue
@mishina2228
Copy link
Contributor Author

These warnings can be seen in the CI on ruby-i18n/i18n.
https://github.com/ruby-i18n/i18n/runs/5191721776?check_suite_focus=true
image

@junaruga
Copy link
Collaborator

junaruga commented Mar 29, 2022

I checked the deprecated messages are printed on the current latest master branch 4c0ccc6 on my local.

$ pwd
/home/jaruga/git/test_declarative

$ bundle install --standalone

$ bundle exec ruby mytest_mini.rb
test_declarative is deprecated for Minitest::Unit::TestCase
test_declarative is deprecated for Minitest::Test
Run options: --seed 5597

# Running:

.

Finished in 0.000541s, 1848.0402 runs/s, 1848.0402 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

I also checked the deprecated messages are not printed on this PR on my local.

$ bundle exec ruby mytest_mini.rb
Run options: --seed 28356

# Running:

.

Finished in 0.000959s, 1042.2118 runs/s, 1042.2118 assertions/s.

1 runs, 1 assertions, 0 failures, 0 errors, 0 skips

@junaruga
Copy link
Collaborator

I think it is because we have defined test method in Module first.

What I don't understand is why Module class is defined as a first element of the targets currently. This issue did not happen in old Rubies?

@svenfuchs Do you have any comments on this?

@mishina2228
Copy link
Contributor Author

mishina2228 commented Mar 30, 2022

This issue did not happen in old Rubies?

At least as of Ruby 1.9.3, these deprecated warnings are printed.

https://github.com/mishina2228/test_declarative/runs/5755153567?check_suite_focus=true
image

I could not check for versions prior to 1.9.3 because ruby/setup-ruby does not support them. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants