Created
January 29, 2014 17:00
-
-
Save fourcube/8692234 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package svv; | |
import org.junit.Before; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.rules.ExpectedException; | |
import org.junit.runner.RunWith; | |
import org.mockito.Mock; | |
import org.mockito.runners.MockitoJUnitRunner; | |
import static org.mockito.Mockito.verifyZeroInteractions; | |
@RunWith(MockitoJUnitRunner.class) | |
public class ExceptionTester { | |
Thrower cut; | |
@Mock | |
Command c; | |
@Rule | |
public ExpectedException exception = ExpectedException.none(); | |
@Before | |
public void setUp() { | |
cut = new Thrower(); | |
} | |
@Test | |
public void shouldThrow() throws Exception { | |
exception.expect(Exception.class); | |
try { | |
cut.now(true); | |
} finally { | |
verifyZeroInteractions(c); | |
} | |
} | |
@Test | |
public void shouldNotThrow() throws Exception { | |
cut.now(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment