Last active
September 27, 2015 10:28
-
-
Save tonypiazza/1255699 to your computer and use it in GitHub Desktop.
Example usage of the expected attribute of the org.junit.Test annotation
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
@Test(expected=ServiceException.class) | |
public void cannotCreateUserWithSameUsername() throws ServiceException { | |
User user1 = new User("Jane", "Smith", "jsmith", "venus"); | |
User user2 = new User("John", "Smith", "jsmith", "mars"); | |
AuctionService service = null; | |
try { | |
service = new BaseAuctionService(); | |
service.saveUser(user1); | |
} catch (ServiceException e) { | |
fail( e.getMessage() ); | |
} | |
service.saveUser(user2); // this should throw ServiceException | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment