Skip to content

Instantly share code, notes, and snippets.

@iyengarajay
Created July 7, 2017 05:00
Show Gist options
  • Save iyengarajay/9894c806667fbd8dae8e85a886a37492 to your computer and use it in GitHub Desktop.
Save iyengarajay/9894c806667fbd8dae8e85a886a37492 to your computer and use it in GitHub Desktop.
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