Created
October 18, 2016 13:36
-
-
Save FranckSilvestre/4a0a36d2b750b795f84c06a4b39bc1ed to your computer and use it in GitHub Desktop.
FriendsOfMine : classe de tests d'intégration pour la classe UtilisateurService
This file contains hidden or 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 friendsofmine | |
| import org.springframework.beans.factory.annotation.Autowired | |
| import org.springframework.boot.test.context.SpringBootTest | |
| import org.springframework.test.context.ContextConfiguration | |
| import spock.lang.Specification | |
| import javax.validation.ConstraintViolationException | |
| /** | |
| * Created by franck on 18/10/2016. | |
| */ | |
| @ContextConfiguration | |
| @SpringBootTest | |
| class UtilisateurServiceITest extends Specification { | |
| @Autowired UtilisateurService utilisateurService | |
| def "test save a valid utilisateur"() { | |
| given: "a valid utilisateur" | |
| Utilisateur bob = new Utilisateur(nom: "Deniro", prenom: "bob", email: "[email protected]",sexe: "M") | |
| when: "the utilisateur is saved" | |
| utilisateurService.saveUtilisateur(bob); | |
| then: "the utilisateur has an id" | |
| bob.id != null | |
| } | |
| def "test save a non valid utilisateur"() { | |
| given: "a non valid utilisateur" | |
| Utilisateur bob = new Utilisateur(prenom: "bob", email: "[email protected]",sexe: "M") | |
| when: "the utilisateur is saved" | |
| utilisateurService.saveUtilisateur(bob); | |
| then: "A validation exception is thrown" | |
| thrown ConstraintViolationException | |
| and: "bob has still null id" | |
| bob.id == null | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment