-
Notifications
You must be signed in to change notification settings - Fork 164
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
Implementation of deprecated typed()
member prevents migration
#188
Comments
Can you give an example? From the Mockito 2.2.2 README, this is how you would use
Mock's noSuchMethod receives the result of |
When you say it drops it on the floor, will it continue to match appropriately? Additionally, if the |
Yes, it's not really in the README, but I'd need to see code that generates the error you see. It looks like you used |
A bawdlerized version of the code follows: when(foo.createBar(id: typed(any as ArgMatcher, named: 'id')))
.thenAnswer((invocation) => new Bar(
id: invocation.namedArguments['id'].toString())); |
Ah, I see. I was pointing to the wrong "named" API. The Upgrading to Mockito 3 doc points to the following syntax, which is valid for the new API in Mockito 3:
This is available as of Mockito 3.0.0-alpha+4, documented in the Upgrading doc as well. |
This doesn't provide a smooth transition path. The package in question exports some of its mocks and so takes mockito as a full dependency. Downstream consumers therefore need to use a compatible version of mockito. It would be necessary to expand the version range to include 3.0.0-alpha+4 but make no changes to retain 2.x compatibility, expand the version range for all consumers, then change to the new API. Is there any chance that |
It looks like the https://github.com/dart-lang/mockito/blob/3.0.0-alpha%2B4/test/mockito_test.dart#L189 I don't have a copy of Dart 1 any more, so I can't execute the tests myself... |
For the reasons stated above, the 3.0.0-alpha+4 transition path isn't a practical option for us due to dependency chains. |
I think you might need to consider forking as a |
@seanburke-wf you stated above:
Why would it not be practical to upgrade all packages to depend on 3.0.0-alpha+4, but it would be practical to upgrade all packages to some yet-to-be-written 2.x? |
The packages in question all have some variant on |
A workaround has been found for the repository in question, which may obviate the need for addressing this upstream. |
When 3.x was released,
typed()
(which was now deprecated) was implemented as an arrow function returningnull
withNull
as the return type in the signature. This means that any code which usestyped()
will cease to function rather than providing a smooth transition, particularly if a dependency chain prevents moving unconditionally to 3.x or greater.The text was updated successfully, but these errors were encountered: