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

@UseModules on test method does not create mocks #80

Open
dnouls opened this issue Apr 13, 2017 · 1 comment
Open

@UseModules on test method does not create mocks #80

dnouls opened this issue Apr 13, 2017 · 1 comment

Comments

@dnouls
Copy link

dnouls commented Apr 13, 2017

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
Copy link
Author

dnouls commented May 29, 2017

No response to this bug report ?

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

No branches or pull requests

1 participant