Skip to content

Instantly share code, notes, and snippets.

View mario-rezende-ifood's full-sized avatar

Mario Rezende mario-rezende-ifood

  • iFood
  • Sao Paulo / Brazil
View GitHub Profile
@Test
void validateUserRegistration() {
// setup
String name = "Fulano"
int age = 20
String email = "fulano@mail.test"
// execute
User user = UserService().register(name, age, email)
@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
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
Condition not satisfied:
Math.max(a, b) == c
| | | | | |
| 7 7 4 | 4
| false
class java.lang.Math
def 'Maximum of two numbers'() {
expect:
Math.max(a, b) == c
where:
a | b | c
1 | 3 | 3
7 | 4 | 4
0 | 0 | 0
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
then:
name == 'Fulano'
name != 'Beltrano'
age >= 20
age < 100