Created
November 15, 2013 20:16
-
-
Save mariuszs/7490875 to your computer and use it in GitHub Desktop.
Checking for 2 expected values in Junit
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
import org.junit.Test; | |
import static com.googlecode.catchexception.CatchException.caughtException; | |
import static com.googlecode.catchexception.apis.CatchExceptionBdd.then; | |
import static com.googlecode.catchexception.apis.CatchExceptionBdd.when; | |
public class SomeTest { | |
SomeService foo; | |
@Test | |
public void testAMethodScenario1() { | |
//given scenario 1 | |
when(foo).amethod(); | |
then(caughtException()) | |
.isInstanceOf(MySystemException.class) | |
.hasMessage("An error occured due to case 1 being incorrect."); | |
} | |
@Test | |
public void testAMethodScenario2() { | |
//given scenario 2 | |
when(foo).amethod(); | |
then(caughtException()) | |
.isInstanceOf(MySystemException.class) | |
.hasMessage("An error occured as case 2 could not be found"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment