Jukito icon indicating copy to clipboard operation
Jukito copied to clipboard

@UseModules on test method does not create mocks

Open dnouls opened this issue 7 years ago • 1 comments

I am trying to create a test where I have a @UseModules on a test mode to setup a dependency different from other test methods. But as a consequence objects are not mocked as is the case with using the @UseModules on the test class.

This unit test show It in action. The testWithoutUseModules gets a mocked HttpServletRequest, while the testWithUseModules gives a Guice error that no implementation was bound for the HttpServletRequest parameter. Maybe I am misreading or misunderstanding it.

@RunWith(JukitoRunner.class)
@UseModules(MockingTest.ModuleA.class)
public class MockingTest {
  @Test
  public void testWithoutUseModules(HttpServletRequest request) {
    assertNotNull(request);
  }

  @Test
  @UseModules(ModuleB.class)
  public void testWithUseModules(HttpServletRequest request) {
    assertNotNull(request);
  }
  public static class ModuleA extends AbstractModule {
    @Override
    protected void configure() {
    }
  }

  public static class ModuleB extends AbstractModule {
    @Override
    protected void configure() {
    }
  }
}

dnouls avatar Apr 13 '17 11:04 dnouls

No response to this bug report ?

dnouls avatar May 29 '17 14:05 dnouls