Full-stack dev quiz question #8

Full-stack dev quiz question #8

quizAttention, 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.

  1. Mocks a local apple variable in the save method.
  2. Checks if the apple local variable used in the save method equals an Apple object with weight = 0.123.
  3. Tests if the save method is executed once with an Apple object that has weight = 0.123.
  4. Does computation. Result of the save method is multiplied by 1 and passed to the lambda expression.
  5. 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.

If you like what I do, consider buying me a coffee :)

Buy me a coffeeBuy me a coffee