Skip to content

Instantly share code, notes, and snippets.

@devkook
Forked from mariuszs/MyTest.java
Created November 27, 2013 07:38
Show Gist options
  • Save devkook/7671991 to your computer and use it in GitHub Desktop.
Save devkook/7671991 to your computer and use it in GitHub Desktop.
import org.junit.Test;
import static com.googlecode.catchexception.CatchException.caughtException;
import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.then;
import static com.googlecode.catchexception.apis.CatchExceptionAssertJ.when;
import static org.mockito.BDDMockito.given;
public class SomeServiceTest {
private SomeService myMock;
@Test
public void testDoThat() {
given(myMock.doSomething()).willThrow(new MyException());
when(myMock).doSomething();
then(caughtException()).isInstanceOf(MyException.class);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment