Skip to content

Conversation

@alanrussian
Copy link
Contributor

Mockito now prohibits calling thenReturn with Futures and Streams. dart-lang/mockito#79

@alanrussian
Copy link
Contributor Author

We have to do a pub release for mockito. It's going to be a 3.0 alpha release. I'll update the pull request with that shortly.

@Hixie
Copy link
Contributor

Hixie commented Dec 12, 2017

Please make sure you did the pubspec.yaml fixes by running flutter update-packages --force-upgrade, not by hand. Thanks.

@alanrussian
Copy link
Contributor Author

Hey @Hixie. Ted did a new release of Mockito. It's an alpha release. When I run that command, it updates it to the latest stable release, not alpha release.

Is there anything I can do to update the deps to the alpha release? I just don't want anyone to cause an accidental breakage in the future.

@Hixie
Copy link
Contributor

Hixie commented Dec 14, 2017

It probably means some other package we depend on depends on a range that doesn't include the new version.

This reverts commit e8ab9d3.

I did not correctly update the mockito dep, and there's no easy way to update to 3.0 alpha right now.
@alanrussian
Copy link
Contributor Author

Ok, I'll just revert the dep change then. Thanks.

@Hixie
Copy link
Contributor

Hixie commented Dec 14, 2017

Rather than _, can you give the type and name of the argument for these callbacks? That will make it easier to understand the code later (when someone looks at the code and wonders what the argument is...).

Other than that, LGTM.

@alanrussian
Copy link
Contributor Author

Done. Thank you.

@alanrussian
Copy link
Contributor Author

alanrussian commented Dec 15, 2017

The lint checks seem to require specifying a type for function expressions. I'm not sure why since this is against Effective Dart (https://www.dartlang.org/guides/language/effective-dart/design#avoid-annotating-types-on-function-expressions). I guess the Flutter style guide is different?

@Hixie How strongly do you feel about "_"? I think reading "Invocation invocation" on each of these is overkill. It looks like there were several calls to thenAnswer with "_" already.

@Hixie
Copy link
Contributor

Hixie commented Dec 16, 2017

Flutter's codebase is intended to be fully typed, so that we don't rely on inference or dynamic. It has frequently helped us catch bugs.

I prefer to have the argument be explicit (in type and in name, so that I can see what it is, and what it means), because otherwise whenever I read this code I'm going to think, "ooh, an argument, I wonder what that is" and have to go look it up instead of just being able to see it.

If you only provide the type (.thenAnswer(Invocation _)) then I'll wonder what the argument is supposed to mean ("is it the "before" invocation? Is it the "answer" of "thenAnswer"? etc). If you only provide the name (.thenAnswer(invocation)) then I'll wonder what the type of the argument is. Is it a string? Is it an Invocation? Is it some custom object that is special for "thenAnswer"?

@alanrussian
Copy link
Contributor Author

alanrussian commented Dec 16, 2017 via email

@alanrussian
Copy link
Contributor Author

@Hixie friendly ping. Would love to get this merged and pulled into g3 ASAP.

@yjbanov yjbanov self-requested a review December 19, 2017 20:44
@yjbanov
Copy link
Contributor

yjbanov commented Dec 19, 2017

Thanks! thenReturn has always been tricky to use, especially when you need to return error futures. LGTM.

lgtm

@yjbanov yjbanov merged commit 30720bd into flutter:master Dec 19, 2017
@alanrussian
Copy link
Contributor Author

Thanks!

DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this pull request May 14, 2018
* Change async stubbing to use thenAnswer.

Mockito now prohibits calling thenReturn with Futures and Streams. dart-lang/mockito#79

* Update all Mockito deps to 3.0.0.

* Revert "Update all Mockito deps to 3.0.0."

This reverts commit e8ab9d3.

I did not correctly update the mockito dep, and there's no easy way to update to 3.0 alpha right now.

* Change thenAnswer((_) => to thenAnswer((invocation) =>

* Add Invocation type to thenAnswer lambdas
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants