Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- `public class AnotherThing {
- private final Something something;
- public AnotherThing(Something something) {
- this.something = something;
- }
- public void doSomething (String s) {
- something.send(s);
- }
- }
- public class Something {
- void send(String s) throws IOException{
- }
- void send(int i) throws IOException{
- }
- }
- import static org.mockito.Matchers.anyString;
- import static org.mockito.Mockito.doThrow;
- import static org.mockito.Mockito.mock;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.mockito.runners.MockitoJUnitRunner;
- @RunWith(MockitoJUnitRunner.class)
- public class OverloadedTest {
- @Test(expected = IllegalStateException.class)
- public void testDoSomething() throws Exception {
- final Something mock = mock(Something.class);
- final AnotherThing anotherThing = new AnotherThing(mock);
- doThrow(new IllegalStateException("failed")).when(anotherThing.doSomething(anyString()));
- }
- }`
Add Comment
Please, Sign In to add comment