Created
March 19, 2015 10:15
-
-
Save FranckSilvestre/2de85b2c32dd4e2701c5 to your computer and use it in GitHub Desktop.
JavaEE - TP3 -Ex1 - q4
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 grails.test.mixin.TestFor | |
import spock.lang.Specification | |
import spock.lang.Unroll | |
/** | |
* See the API for {@link grails.test.mixin.domain.DomainClassUnitTestMixin} for usage instructions | |
*/ | |
@TestFor(Utilisateur) | |
class UtilisateurSpec extends Specification { | |
@Unroll | |
void "test la validite d'un utilisateur valide"(String unNom, String unPrenom, String unEmail, String unSexe, Date uneDateNaissance) { | |
given: "un utilisateur initialise correctement" | |
Utilisateur utilisateur = new Utilisateur(nom: unNom, prenom: unPrenom, email: unEmail, sexe: unSexe, dateNaissance: uneDateNaissance) | |
expect: "l'utilisateur est valide" | |
utilisateur.validate() == true | |
and: "il n'est proprietaire d'aucune activite" | |
!utilisateur.activites | |
where: | |
unNom | unPrenom | unEmail | unSexe | uneDateNaissance | |
"Dupont" | "Jeanne" | "[email protected]" | "F" | new Date(1972, 6, 17) | |
"Durand" | "Jacques" | "[email protected]" | "M" | new Date(1972, 6, 17) | |
"Durand" | "Jacques" | "[email protected]" | "M" | null | |
} | |
@Unroll | |
void "test l'invalidite d'un utilisateur non valide"(String unNom, String unPrenom, String unEmail, String unSexe) { | |
given: "un utilisateur initialise de maniere non valide" | |
Utilisateur utilisateur = new Utilisateur(nom: unNom, prenom: unPrenom, email: unEmail, sexe: unSexe) | |
expect: "l'utilisateur est invalide" | |
utilisateur.validate() == false | |
where: | |
unNom | unPrenom | unEmail | unSexe | |
null | "Jeanne" | "[email protected]" | "F" | |
'' | "Jeanne" | "[email protected]" | "F" | |
"Dupont" | null | "[email protected]" | "F" | |
"Durand" | "" | "[email protected]" | "M" | |
"Durand" | "Jacques" | "jdjd.com" | "M" | |
"Durand" | "Jacques" | null | "M" | |
"Durand" | "Jacques" | "[email protected]" | "Z" | |
"Durand" | "Jacques" | "[email protected]" | null | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment