Attention, attention! Testing knowledge is required. The eighth question of the quiz for a full-stack developer is about Spock Framework.
SetTimeout seems familiar? Check the answer to the seventh question.
The below code is Groovy with Spock Framework.
1 * basketsRepository.save(_) >> { arguments ->
final Apple apple = arguments.get(0)
assert apple == new Apple(weight: 0.123) }
What does it do? Choose one answer.
- Mocks a local apple variable in the save method.
- Checks if the apple local variable used in the save method equals an Apple object with weight = 0.123.
- Tests if the save method is executed once with an Apple object that has weight = 0.123.
- Does computation. Result of the save method is multiplied by 1 and passed to the lambda expression.
- Stubs a method. When the save method is executed for the first time, an Apple object with weight = 0.123 is returned.
For the answer scroll down
.
.
.
.
.
.
The correct answer is c. For more information about it, see Testing arguments of method execution with Spock Framework.