Created
April 2, 2012 19:23
-
-
Save php-coder/2286536 to your computer and use it in GitHub Desktop.
@dataProvider example
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
@Test(dataProvider = "invalidEmails") | |
public void emailShouldBeValid(final String invalidEmail, final String expectedMessage) { | |
page.registerUser(invalidEmail); | |
assertThat(page).field("email").hasError(expectedMessage); | |
} | |
@DataProvider(name = "invalidEmails") | |
public Object[][] getInvalidEmails() { | |
final String expectedErrorMessage = | |
tr("ru.mystamps.web.validation.jsr303.Email.message"); | |
return new Object[][] { | |
{"login", expectedErrorMessage}, | |
{"login@domain", expectedErrorMessage} | |
}; | |
} |
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
@Test | |
public void emailShouldBeValid() { | |
final String[] emails = new String[] { | |
"login", | |
"login@domain" | |
}; | |
for (final String invalidEmail : emails) { | |
page.registerUser(invalidEmail); | |
assertThat(page) | |
.field("email") | |
.hasError(tr("ru.mystamps.web.validation.jsr303.Email.message")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment