Created
March 5, 2015 09:29
-
-
Save FranckSilvestre/ca89f0de443cb2047fe1 to your computer and use it in GitHub Desktop.
Spécification de la classe Utilisateur sur le projet FriendsOfMine
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 | |
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