flutter_gherkin/test/mocks/step_definition_mock.dart

25 lines
563 B
Dart
Raw Normal View History

import 'package:gherkin/gherkin.dart';
2018-10-26 10:09:22 +00:00
typedef OnRunCode = Future<void> Function(Iterable parameters);
2018-10-26 10:09:22 +00:00
class MockStepDefinition extends StepDefinitionBase<World> {
2018-10-26 10:09:22 +00:00
bool hasRun = false;
int runCount = 0;
final OnRunCode? code;
2018-10-26 10:09:22 +00:00
2019-02-06 01:09:07 +00:00
MockStepDefinition([this.code, int expectedParameterCount = 0])
: super(null, expectedParameterCount);
2018-10-26 10:09:22 +00:00
@override
Future<void> onRun(Iterable parameters) async {
hasRun = true;
runCount += 1;
if (code != null) {
await code!(parameters);
2018-10-26 10:09:22 +00:00
}
}
@override
RegExp get pattern => RegExp('');
2018-10-26 10:09:22 +00:00
}