Skip to content
This repository was archived by the owner on Feb 13, 2026. It is now read-only.

Expose mock method api#89

Open
zbynek wants to merge 1 commit intogoogle:masterfrom
zbynek:mock-method-api
Open

Expose mock method api#89
zbynek wants to merge 1 commit intogoogle:masterfrom
zbynek:mock-method-api

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
Contributor

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 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.

2 participants

Comments