-
-
Notifications
You must be signed in to change notification settings - Fork 158
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
Expectation ignored when test cases are run in a certain order #298
Comments
@skliew: Thanks for reporting this issue. Setting an expectation on any instance of |
I actually found this problem in a real code base when a test case occasionally fails. I have to admit that the test case was itself buggy, as most of the time false positives are reported. And thanks for the great library :) |
@skliew Hmm. Sorry for taking so long to get back to you. I just did a bit of digging and it appears this might be a more fundamental problem with the Test::Unit integration. I'm continuing to investigate. |
I take back my last comment about it being a more fundamental problem. I made the mistake of looking at this before I'd had any coffee! I'm continuing to investigate. |
Previously ObjectMethods#mocha & ClassMethods::AnyInstance#mocha were building mock objects for ancestor classes when ObjectReceiver#mocks or AnyInstanceReceiver#mocks was called from Mock#all_expectations as part of Mock#method_missing. Since these mock objects were not associated with a corresponding ClassMethod or AnyInstanceMethod registered with Central via Mockery#mock_impersonating or Mockery#mock_impersonating_any_instance_of, they were not being reset as part of Central#unstub_all via Mockery#teardown and this state was leaking into subsequent tests. You can see an example of this in #298. I've captured a more general case of this in the new acceptance test method in StubAnyInstanceMethodDefinedOnSuperclassTest which was failing before the fix in this commit. I've also added a similar acceptance test method to StubClassMethodDefinedOnSuperclassTest which was also failing before the fix in this commit. I'm not particularly happy with the fix, but I think it'll do for now.
Found this issue using version
1.2.1
. In the code example as follows,test_case_2
passes even when there is no call to any method namedtest1
, resulting in a false positive:Do note that when the line
SUT.new.test1
is commented out, both test cases fail. And whentest_case_2
is run beforetest_case_1
, onlytest_case_2
fails which should be the correct behavior.The text was updated successfully, but these errors were encountered: