Skip to content

Instantly share code, notes, and snippets.

@itzg
Created September 24, 2012 17:51
Show Gist options
  • Select an option

  • Save itzg/3777275 to your computer and use it in GitHub Desktop.

Select an option

Save itzg/3777275 to your computer and use it in GitHub Desktop.
public class SomeManagedBean {
private ServiceA someService;
public int doSomething() {
... logic to be tested ...
someService.doSomethingElse();
}
public void setSomeService(ServiceA someService) {
this.someService = someService;
}
}
}
public class SomeManagedBeanTest {
@Test
public void doSomethingTest() {
SomeManagedBean testMe = new SomeManagedBean();
testMe.setSomeService(new MockServiceA());
int actualResult = testMe.doSomething();
assertEquals(1, actualResult);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment