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

mocktail could offer string diffs on call failures? #208

Open
eseidel opened this issue Sep 6, 2023 · 2 comments
Open

mocktail could offer string diffs on call failures? #208

eseidel opened this issue Sep 6, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@eseidel
Copy link

eseidel commented Sep 6, 2023

For long strings it can be very hard to figure out how to match calls exactly. e.g.:

      verify(
        () => logger.info('''

Your next step is to upload the app bundle to the Play Store:
build/app/outputs/bundle/release/app-release.aab

Or distribute the apk:
build/app/outputs/apk/release/app-release.apk

For information on uploading to the Play Store, see: 
${link(uri: Uri.parse('https://support.google.com/googleplay/android-developer/answer/9859152?hl=en'))}
'''),

I get the message:

00:01 +304 ~1 -1: test/src/commands/release/release_android_command_test.dart: ReleaseAndroidCommand succeeds when release is successful (with apk) [E]                                                
  No matching calls. All calls: _MockLogger.progress(Building release, {options: null}),
  _MockLogger.progress(Detecting release version, {options: null}),
  _MockLogger.info(
      
      🚀 Ready to create a new release!
      
      📱 App: Test App (test-app-id)
      📦 Release Version: 1.2.3+1
      🕹️  Platform: android (arm64, arm32, x86_64)
      , {style: null}),
  _MockLogger.confirm(Would you like to continue?, {defaultValue: false}),
  [VERIFIED] _MockLogger.success(
      
      ✅ Published Release!, {style: null}),
  _MockLogger.info(
      
      Your next step is to upload the app bundle to the Play Store:
      build/app/outputs/bundle/release/app-release.aab
      
      Or distribute the apk:
      build/app/outputs/apk/release/app-release.apk
      
      For information on uploading to the Play Store, see: 
      https://support.google.com/googleplay/android-developer/answer/9859152?hl=en
      , {style: null})
  (If you called `verify(...).called(0);`, please instead use `verifyNever(...);`.)
  package:matcher                                                     fail
  package:mocktail/src/mocktail.dart 728:7                            _VerifyCall._checkWith
  package:mocktail/src/mocktail.dart 519:18                           _makeVerify.<fn>
  test/src/commands/release/release_android_command_test.dart 374:13  main.<fn>.<fn>

I'm clearly very close, but not quite right yet. Mocktail could theoretically detect this and offer me a string difference to help see where my error is. 🤷 That may be out of scope for mocktail though.

package:test has some decent string diffing code (I even used it in a recent fun project):
https://github.com/dart-lang/test/blob/2cb07a3f4d16b74f1181bd8f963d342db5a8e6b0/pkgs/checks/lib/src/extensions/string.dart

@eseidel
Copy link
Author

eseidel commented Sep 6, 2023

Turns out it was just me missing a "lightCyan.wrap" around my apk/aab paths in the above. 🤷

@renancaraujo
Copy link
Collaborator

The matcher "equals" has some nice string diff outputs (as well as for collections). Mocktail could it use its "describeMismatch" for this

@felangel felangel added the enhancement New feature or request label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants