captured property

List captured

List of all arguments captured in real calls.

This list will include any captured default arguments and has no structure differentiating the arguments of one call from another. Given the following class:

class C {
  String methodWithPositionalArgs(int x, [int y]) => '';
  String methodWithTwoNamedArgs(int x, {int y, int z}) => '';
}

the following stub calls will result in the following captured arguments:

mock.methodWithPositionalArgs(1);
mock.methodWithPositionalArgs(2, 3);
var captured = verify(
  () => mock.methodWithPositionalArgs(
    captureAny(), captureAny(),
   )
).captured;
print(captured); // Prints "[1, null, 2, 3]"

mock.methodWithTwoNamedArgs(1, y: 42, z: 43);
mock.methodWithTwoNamedArgs(1, y: 44, z: 45);
var captured = verify(
    () => mock.methodWithTwoNamedArgs(
      any(),
      y: captureAny(named: 'y'),
      z: captureAny(named: 'z'),
    ),
).captured;
print(captured); // Prints "[42, 43, 44, 45]"

Implementation

// ignore: unnecessary_getters_setters
List<dynamic> get captured => _captured;