-
-
Save iyengarajay/9894c806667fbd8dae8e85a886a37492 to your computer and use it in GitHub Desktop.
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
package com.boot.test.db; | |
import com.boot.entity.EmailAddress; | |
import spock.lang.Specification | |
public class EmailAddressTest extends Specification { | |
private static final String testEmail = "test@test.com"; | |
def "throw exception for invalid format of email address"(String emailAddress) | |
{ | |
when: | |
"create invalid email address" | |
def email = new EmailAddress(emailAddress); | |
then: | |
"throw exception for invalid format of email address" | |
def e = thrown(IllegalArgumentException) | |
e.message == "Email Address is Invalid !" | |
where: | |
emailAddress | _ | |
"test@.com" | _ | |
" " | _ | |
null | _ | |
} | |
def "return valid email address"() | |
{ | |
when: | |
"create new email address" | |
def email = new EmailAddress(testEmail); | |
then: | |
"return valid email" | |
email.toString() == testEmail; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment