Skip to content

Instantly share code, notes, and snippets.

@HeartSaVioR
Last active December 17, 2015 23:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save HeartSaVioR/5693710 to your computer and use it in GitHub Desktop.
Save HeartSaVioR/5693710 to your computer and use it in GitHub Desktop.
JUnit : assert Exception
import org.junit.Test;
import org.junit.Rule;
import org.junit.rules.ExpectedException;
public class JUnitExceptionTest {
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
public void testDoWork() {
exception.expect(IllegalStateException.class);
throw new IllegalStateException();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment