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

Expose mock method api #89

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

zbynek
Copy link
Contributor

@zbynek zbynek commented Oct 1, 2020

When used with Elemental it's quite handy to be able to override Js.asPropertyMap and other static methods to return something remotely useful. Providing list of such methods is not in the scope of this PR, but by exposing the necessary API anyone can subclass GwtMockitoRunner and mock the methods in their implementation. The alternative -- mocking those methods using powermock or mockito inline -- is very cumbersome because of the different classsloaders.

@zbynek
Copy link
Contributor Author

zbynek commented Oct 12, 2020

@ekuefler could you please check this PR?

@ekuefler
Copy link
Collaborator

Thanks for the PR. I see the value of this but am hesitant to expose any API in StubGenerator - like the javadoc in that class mentions, that class (and the rest of the impl package) is intended to be called only by generated code and not invoked by users directly. There might also be some unexpected behavior since StubGenerator is invoked only in certain circumstances:

if (returnType.isPrimitive() || returnType.getName().equals("void")) {

Do you think it would be possible to expose this API via a protected method on GwtMockitoTestRunner that users could override? Something like getMethodsToReplace that returns a collection of ReplacementMethods, which each defines a class, name, and implementation function? GwtMockitoTestRunner could then consult that method before going through the internal stub generator.

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

Successfully merging this pull request may close these issues.

2 participants