-
Notifications
You must be signed in to change notification settings - Fork 550
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
MiniTest 5.11.0 -- error or failure also causes undefined method (for test name) backtrace #730
Comments
Same here, seems to be a problem with Rails::TestUnitReporter def format_rerun_snippet(result)
location, line = result.method(result.name).source_location
"#{executable} #{relative_path_for(location)}:#{line}"
end As Minitest passes now a Minitest::Result object to the reporter which does not have the test method: Here is our travis run: We updated from minitest (5.10.3) to minitest (5.11.0) which caused this error. |
Storing the runnable in the result objet and adding an around alias for the def self.from runnable
o = runnable
r = self.new o.name
r.klass = o.class.name
r.assertions = o.assertions
r.failures = o.failures.dup
r.time = o.time
r.runnable = o
r.source_location = o.method(o.name).source_location rescue ["unknown", -1]
r
end
alias :orig_method :method
def method method_name
self.orig_method(method_name)
rescue
self.runnable.method(method_name)
end |
UGH. I even asked @tenderlove to poke at this before the release. :( I cannot and will not store the runnable in the Result. That's the whole point of the Result object. Can you try: def format_rerun_snippet(result)
location, line = if result.respond_to?(:source_location) then
result.source_location
else
result.method(result.name).source_location
end
"#{executable} #{relative_path_for(location)}:#{line}"
end I could also see doing a patch that has a dummy method object returned. |
Possible: class Minitest::Result
def method name
o = Object.new
def o.source_location
["unknown", -1]
end
end
end |
Nevermind... This should be related to #729. Rails just makes it a lot messier looking. I have a fix that will be out shortly. |
Released 5.11.1. This should be fixed. Thanks! |
c & p from #732 Unfortunately I can not reopen #730 so I'm opening a new one. Release 5.11.1 did not fix the issue, I still get the same error (see #730). From my POV #729 and #730 are unrelated. class Minitest::Result
def method name
o = Object.new
def o.source_location
["unknown", -1]
end
end
end Your suggestion did fix the issue, however, wouldn't that be always return ["unknown", -1] for source location? Also it would return just an Object instead of a MethodObject. What about only storing the MethodObject instead of only the source location? This also worked for me: def method name
if name.to_sym == method_object.name
method_object
else
orig_method(name)
end
end Your other suggestions would require to patch ActiveSupport, no? |
Storing off the method maintains a binding to the original object, which is exactly what we're trying to avoid. I could try to anticipate the source location asked for and store that off? |
Here are two working proposals, one for patching minitest and one for rails. I might want both, tho the minitest one feels gross. require "minitest/autorun"
if ENV["MT"] then
class Minitest::Result
def method name
self.instance_of?(Minitest::Result) && name == self.name ? self : super
end
end
end
describe "Whatever" do
it 'with an error' do
assert_equal 1, -1
end
def format_rerun_snippet(result) # from rails
location, line =
if ENV["RAILS"] then
if result.respond_to?(:source_location) then
result.source_location
else
result.method(result.name).source_location
end
else
result.method(result.name).source_location
end
"executable #{location}:#{line}"
end
def run(*a) # emulate rails
result = super
puts format_rerun_snippet result unless result.passed?
result
end
end |
Also, please file a bug on rails and link back to here... [ETA: nevermind] |
Linking to rails/rails#31624 |
Thanks for your proposal. |
The same for me. Since minitest 5.11, each failure or error in tests aborts the whole testing with class `Minitest::Result' (NameError). |
Works around issue minitest/minitest#730
Work around for minitest/minitest#730
I’m working with @tenderlove to figure out the best way to go with this. Until then, feel free to steal off the |
This has been fixed in rails. Thanks everyone. Poke me if there are futher problems. |
@zenspider i see that tenderlove merged Rails PR #31624 to master, but just confirming: that's not in any Rails release yet, right? Is the simplest thing for now to just lock MiniTest version to 5.10.3 in our Gemfiles until a new Rails release drops? |
@zenspider How has it been fixed in Rails. Do you mean the workaround with the gemfile.lock is the fix or is there a new Rails release with the fix? |
@acousma82 see the PR link in the comment above yours. No, a release isn't out yet. You can run on edge rails to get this fix. (cc/ @jm3) I'm not hooked in enough to know when a rails release will happen. Comment on the rails PR if you want to poke at it. |
I'm seeing a require 'minitest/autorun'
require 'set'
class TestSet < Minitest::Test
def test_empty
set= Set.new
assert_empty set
set.add(0)
assert_empty set
end
end And, running the test:
What I can't seem to figure out is why Rails' TestUnit reporter is getting loaded when I'm only requiring |
Looking at your error it looks like you're trying to call asset_empty, not assert_empty.
|
There is an issue with minitest 5.11.x + Rails 5.1. It should be fixed in Rails (rails/rails#30800), however, it's not released yet. 5.11.x gives us issues described in minitest/minitest#730.
See issue #730 on minitest/minitest#730 - I used one of the suggested workarounds and switched the minitest version in the gemfile The fixtures needed id's because submissions belong to users
Was hitting this minitest/minitest#730
Disables built-in 'rails' Minitest plugin due to incompatibility with Minitest >= 5.11. minitest/minitest#730 This issue will be fixed in Rails >= 5.2.x, so this workaround can be removed after upgrading. rails/rails#31624
As described in minitest/minitest#730, minitest `v5.11.x` and Rails `<= 5.1.4` don't play well together. Bugfix to support minitest `5.11.x` was added in rails/rails#31624, which was included in the release of Rails `5.1.5`.
Merge pull request rails#31624 from y-yagi/fix_minitest_511 Add support for Minitest 5.11 cherry-pick 0552bca `Minitest::Result` can't use in 5-0-stable Because Minitest is locked by 5.3.3. cherry-pick f7e5f19 Fixes ``` rails/railties/lib/rails/test_unit/reporter.rb:70:in `method': undefined method `test_the_truth' for class `Minitest::Result' (NameError) ``` Related to minitest/minitest#730
Pinned minitest to v5.10.0 because of minitest/minitest#730 This issue has been corrected in in Rails 5.1 https://issues.umd.edu/browse/LIBITD-1220
Pinned minitest to v5.10.0 because of minitest/minitest#730 This issue has been corrected in in Rails 5.1 https://issues.umd.edu/browse/LIBITD-1231
I got back into the project this morning and noticed a TON of test failures in recent PRs. 5 min of research led me to these issues in recent versions of minitest and Rails. Since we use a variety of Rails versions, pinning the version minitest to one that works across legacy Rails versions is a solution for today, but we may have to take a look at a more sophisticated solution in the future. minitest/minitest#730 rails/rails#31624
Quickfix: |
Minitest 5.11.0
When an error code E or a faulure code F is returned for a test, an 'undefined method for (test name here)' error with backtrace is generated.
Example:
The line fails because of assrt_equal with this backtrace:
Under Minitest 5.10.3, the no method error and backtrace do not appear.
The text was updated successfully, but these errors were encountered: