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
@Test | |
void validateUserRegistration() { | |
// setup | |
String name = "Fulano" | |
int age = 20 | |
String email = "fulano@mail.test" | |
// execute | |
User user = UserService().register(name, age, email) |
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
@Unroll | |
def 'Maximum of #a and #b is #c'() { | |
expect: | |
Math.max(a, b) == c | |
where: | |
a | b | c | |
1 | 3 | 3 | |
7 | 4 | 4 |
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
maximum of 1 and 3 is 3 PASSED | |
maximum of 7 and 4 is 4 FAILED | |
Math.max(a, b) == c | |
| | | | | | | |
| 7 7 4 | 4 | |
| false | |
class java.lang.Math | |
maximum of 0 and 0 is 0 PASSED |
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
Condition not satisfied: | |
Math.max(a, b) == c | |
| | | | | | | |
| 7 7 4 | 4 | |
| false | |
class java.lang.Math |
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
def 'Maximum of two numbers'() { | |
expect: | |
Math.max(a, b) == c | |
where: | |
a | b | c | |
1 | 3 | 3 | |
7 | 4 | 4 | |
0 | 0 | 0 |
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
def 'Allow user access only for 18 over'(name, age, expected) { | |
given: 'user entity' | |
def user = new User(name, age) | |
when: 'validate user access' | |
def userCanAccess = AccessService().grantUser(user) | |
then: | |
userCanAccess == expected |
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
then: | |
name == 'Fulano' | |
name != 'Beltrano' | |
age >= 20 | |
age < 100 |
NewerOlder