Hello,

I ran into the exact same problem like Matthew. Are there any plans to 
support mocking static methods in Dropwizard?

Cheers,
Jan


Am Dienstag, 30. Juni 2015 23:20:04 UTC+2 schrieb Matthew Chen:
>
> I need to mock a static method of a class and use that mocked method in my 
> test. Right now seems I can only use PowerMock to do that.
>
> So i added below dependencies:
>             'org.powermock:powermock-module-junit4', 
>             'org.powermock:powermock-module-junit4-rule-agent', 
>             'org.powermock:powermock-api-mockito', 
>
> Then I annotate the class with @RunWith(PowerMockRunner.class), and 
> @PrepareForTest with the appropriate class.
>
> In my test I have a @ClassRule which is instance of ResourceTestRule
>
> When running the tests, the rule is not applied properly, so 
> resources.getJerseyTest() or resources.client() are both null.
>
> I was hope there's a good runner that will take care of the class rules or 
> the DW framework has a mocking API for static or constructor?
>
> Any idea how this can be resolved? Btw, the mocked method is from a 
> dependency class, so I don't have the option to create a factory and mock 
> factory methods to mock the static method.
>
> Thanks,
>

-- 
You received this message because you are subscribed to the Google Groups 
"dropwizard-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to