Guest User

Untitled

a guest
Jan 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. `public class AnotherThing {
  2. private final Something something;
  3.  
  4. public AnotherThing(Something something) {
  5. this.something = something;
  6. }
  7.  
  8. public void doSomething (String s) {
  9. something.send(s);
  10. }
  11. }
  12.  
  13. public class Something {
  14.  
  15. void send(String s) throws IOException{
  16.  
  17. }
  18.  
  19. void send(int i) throws IOException{
  20.  
  21. }
  22. }
  23.  
  24. import static org.mockito.Matchers.anyString;
  25. import static org.mockito.Mockito.doThrow;
  26. import static org.mockito.Mockito.mock;
  27.  
  28. import org.junit.Test;
  29. import org.junit.runner.RunWith;
  30. import org.mockito.runners.MockitoJUnitRunner;
  31.  
  32. @RunWith(MockitoJUnitRunner.class)
  33. public class OverloadedTest {
  34.  
  35. @Test(expected = IllegalStateException.class)
  36. public void testDoSomething() throws Exception {
  37. final Something mock = mock(Something.class);
  38. final AnotherThing anotherThing = new AnotherThing(mock);
  39.  
  40. doThrow(new IllegalStateException("failed")).when(anotherThing.doSomething(anyString()));
  41. }
  42. }`
Add Comment
Please, Sign In to add comment