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

GenerateMocks not properly generating mocks that use the Diagnosticable mixin #397

Closed
arthurpiccoli opened this issue Apr 27, 2021 · 3 comments

Comments

@arthurpiccoli
Copy link

After generating the following mock class:
class _FakeTextStyle extends _i1.Fake implements _i12.TextStyle {}

This error occurred:
'Object.toString' ('String Function()') isn't a valid concrete implementation of 'Diagnosticable.toString' ('String Function({DiagnosticLevel minLevel})')

It happened due to the toString method on Diagnosticable dependent classes, as TextStyle being one, having a different format, needing a DiagnosticLevel as param. This simple solution did the trick, but it was necessary to edit the generated file:

class _FakeTextStyle extends _i1.Fake implements _i12.TextStyle {
  @override
  String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
    return super.toString();
  }
}
@srawlins
Copy link
Member

Thanks for opening an issue. This has been discussed at #233. See the solution.

@safarmer
Copy link

@srawlins the solution in #233 only seems to cover manually created mocks? How would we apply this to @GeneratedMocks?

@srawlins
Copy link
Member

Oops, apologies. You are correct; that solution works for manual mocks. This issue is actually a duplicate of #371.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants