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

Testing becomes impossible #170

Closed
RafaRuiz opened this issue Sep 29, 2021 · 5 comments · Fixed by #226
Closed

Testing becomes impossible #170

RafaRuiz opened this issue Sep 29, 2021 · 5 comments · Fixed by #226
Labels
enhancement New feature or request platform-dart Specific to Dart code

Comments

@RafaRuiz
Copy link
Contributor

When having all calls static, testing this is impossible.
Would it be good to create an aside "instance" that starts with an initialization then with that object, you can call anything else?

Example:
Instead of:

Intercom.initialize().then((_) => Intercom.displayMessenger());

I would do:

class Intercom ... 

Intercom._();

static Future<Intercom> initialize(...) { ... }

void displayMessenger() { }
// ... other methods

I can submit a PR for this.

@deepak786
Copy link
Collaborator

@RafaRuiz
I don't think that this is necessary. Also, this would be a breaking change.

is there an issue using the static functions?

@RafaRuiz
Copy link
Contributor Author

RafaRuiz commented Sep 29, 2021

It would be a breaking change, but we can go step by step (deprecating).
If all the methods are static, we can't mock them with mockito or mocktail

Imagine I want to mock that the initialization worked but displayMessenger didn't, for some reason. I can't do that with the current implementation

@deepak786
Copy link
Collaborator

@Zazo032 what do you think about this?

@Zazo032
Copy link
Collaborator

Zazo032 commented Sep 30, 2021

I like the instance approach, Firebase plugins did the same thing, and if it helps on the testing side, I think there are no downsides. However, we should do the addition, deprecation and removal in different releases

@Zazo032 Zazo032 added enhancement New feature or request platform-dart Specific to Dart code labels Sep 30, 2021
@deepak786
Copy link
Collaborator

We can't have both static and instance members with the same name dart-lang/language#1711
So to implement the instance approach, we have to delete the static methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform-dart Specific to Dart code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants