feat(expressions): now evaluating tag expressions before running a scenario
This commit is contained in:
parent
2727535321
commit
d4c43aa0a3
|
@ -1 +1 @@
|
|||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\integration_test-1.0.1\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\integration_test-1.0.1\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-01-14 08:07:08.545183","version":"1.22.5"}
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\integration_test-1.0.1\\\\","dependencies":[]}],"android":[{"name":"integration_test","path":"C:\\\\Google\\\\flutter\\\\.pub-cache\\\\hosted\\\\pub.dartlang.org\\\\integration_test-1.0.1\\\\","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"integration_test","dependencies":[]}],"date_created":"2021-01-14 09:52:04.710","version":"1.22.5"}
|
|
@ -9,6 +9,7 @@ Feature: Creating todos
|
|||
| Todo |
|
||||
| Buy carrots |
|
||||
|
||||
@debug
|
||||
Scenario: User can create multiple new todo items
|
||||
Given I fill the "todo" field with "Buy carrots"
|
||||
When I tap the "add" button
|
||||
|
|
|
@ -17,6 +17,7 @@ FlutterTestConfiguration gherkinTestConfiguration =
|
|||
whenAnAnimationIsAwaited,
|
||||
],
|
||||
)
|
||||
// ..tagExpression = '@debug'
|
||||
..hooks = [
|
||||
ResetAppHook(),
|
||||
]
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -51,7 +51,7 @@ class _CustomGherkinIntegrationTestRunner extends GherkinIntegrationTestRunner {
|
|||
|
||||
runScenario(
|
||||
'User can create multiple new todo items',
|
||||
<String>['@tag'],
|
||||
<String>['@tag', '@debug'],
|
||||
(TestDependencies dependencies) async {
|
||||
await runStep(
|
||||
'Given I fill the "todo" field with "Buy carrots"',
|
||||
|
|
|
@ -254,8 +254,8 @@ packages:
|
|||
dependency: transitive
|
||||
description:
|
||||
path: "."
|
||||
ref: "6db02b6553200ea498c24315dc18373a6682fe7d"
|
||||
resolved-ref: "6db02b6553200ea498c24315dc18373a6682fe7d"
|
||||
ref: f0b3f955191b53a78075ed2c9387ea8bee12f111
|
||||
resolved-ref: f0b3f955191b53a78075ed2c9387ea8bee12f111
|
||||
url: "https://github.com/jonsamwell/dart_gherkin.git"
|
||||
source: git
|
||||
version: "1.1.10"
|
||||
|
|
|
@ -16,6 +16,8 @@ class TestDependencies {
|
|||
}
|
||||
|
||||
abstract class GherkinIntegrationTestRunner {
|
||||
final TagExpressionEvaluator _tagExpressionEvaluator =
|
||||
TagExpressionEvaluator();
|
||||
final TestConfiguration configuration;
|
||||
final void Function(World world) appMainFunction;
|
||||
Reporter _reporter;
|
||||
|
@ -120,63 +122,72 @@ abstract class GherkinIntegrationTestRunner {
|
|||
Iterable<String> tags,
|
||||
Future<void> Function(TestDependencies dependencies) runTest,
|
||||
) {
|
||||
testWidgets(
|
||||
name,
|
||||
(WidgetTester tester) async {
|
||||
final debugInformation = RunnableDebugInformation('', 0, name);
|
||||
final scenarioTags =
|
||||
(tags ?? Iterable<Tag>.empty()).map((t) => Tag(t, 0));
|
||||
final dependencies = await createTestDependencies(
|
||||
configuration,
|
||||
tester,
|
||||
);
|
||||
if (_evaluateTagFilterExpression(configuration.tagExpression, tags)) {
|
||||
testWidgets(
|
||||
name,
|
||||
(WidgetTester tester) async {
|
||||
final debugInformation = RunnableDebugInformation('', 0, name);
|
||||
final scenarioTags =
|
||||
(tags ?? Iterable<Tag>.empty()).map((t) => Tag(t, 0));
|
||||
final dependencies = await createTestDependencies(
|
||||
configuration,
|
||||
tester,
|
||||
);
|
||||
|
||||
await _hook.onBeforeScenario(
|
||||
configuration,
|
||||
name,
|
||||
scenarioTags,
|
||||
);
|
||||
|
||||
await startApp(
|
||||
tester,
|
||||
dependencies.world,
|
||||
);
|
||||
|
||||
await _hook.onAfterScenarioWorldCreated(
|
||||
dependencies.world,
|
||||
name,
|
||||
scenarioTags,
|
||||
);
|
||||
|
||||
await reporter.onScenarioStarted(
|
||||
StartedMessage(
|
||||
Target.scenario,
|
||||
await _hook.onBeforeScenario(
|
||||
configuration,
|
||||
name,
|
||||
debugInformation,
|
||||
scenarioTags,
|
||||
),
|
||||
);
|
||||
);
|
||||
|
||||
await runTest(dependencies);
|
||||
await startApp(
|
||||
tester,
|
||||
dependencies.world,
|
||||
);
|
||||
|
||||
await _reporter.onScenarioFinished(
|
||||
ScenarioFinishedMessage(
|
||||
await _hook.onAfterScenarioWorldCreated(
|
||||
dependencies.world,
|
||||
name,
|
||||
debugInformation,
|
||||
true,
|
||||
),
|
||||
);
|
||||
scenarioTags,
|
||||
);
|
||||
|
||||
await _hook.onAfterScenario(
|
||||
configuration,
|
||||
name,
|
||||
scenarioTags,
|
||||
);
|
||||
await reporter.onScenarioStarted(
|
||||
StartedMessage(
|
||||
Target.scenario,
|
||||
name,
|
||||
debugInformation,
|
||||
scenarioTags,
|
||||
),
|
||||
);
|
||||
|
||||
cleanupScenarioRun(dependencies);
|
||||
},
|
||||
timeout: scenarioExecutionTimeout,
|
||||
);
|
||||
await runTest(dependencies);
|
||||
|
||||
await _reporter.onScenarioFinished(
|
||||
ScenarioFinishedMessage(
|
||||
name,
|
||||
debugInformation,
|
||||
true,
|
||||
),
|
||||
);
|
||||
|
||||
await _hook.onAfterScenario(
|
||||
configuration,
|
||||
name,
|
||||
scenarioTags,
|
||||
);
|
||||
|
||||
cleanupScenarioRun(dependencies);
|
||||
},
|
||||
timeout: scenarioExecutionTimeout,
|
||||
);
|
||||
} else {
|
||||
_safeInvokeFuture(
|
||||
() async => reporter.message(
|
||||
'Ignoring scenario `${name}` as tag expression `${configuration.tagExpression}` not satisfied',
|
||||
MessageLevel.info,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@protected
|
||||
|
@ -388,4 +399,13 @@ abstract class GherkinIntegrationTestRunner {
|
|||
await fn().catchError((_, __) {});
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
bool _evaluateTagFilterExpression(
|
||||
String tagExpression,
|
||||
List<String> tags,
|
||||
) {
|
||||
return tagExpression == null || tagExpression.isEmpty
|
||||
? true
|
||||
: _tagExpressionEvaluator.evaluate(tagExpression, tags);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:flutter_gherkin/flutter_gherkin.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
/// The world object that can be used to store state during a single test.
|
||||
/// It also allows interaction with the app under test through the `appDriver`
|
||||
/// which exposes an instance of `AppDriverAdapter` and an
|
||||
/// instance of `WidgetTester` via the property `rawAppDriver`
|
||||
class FlutterWidgetTesterWorld<WidgetTester>
|
||||
extends FlutterWorld<WidgetTester> {}
|
||||
class FlutterWidgetTesterWorld extends FlutterWorld<WidgetTester> {}
|
||||
|
|
|
@ -165,8 +165,8 @@ packages:
|
|||
dependency: "direct main"
|
||||
description:
|
||||
path: "."
|
||||
ref: "6db02b6553200ea498c24315dc18373a6682fe7d"
|
||||
resolved-ref: "6db02b6553200ea498c24315dc18373a6682fe7d"
|
||||
ref: f0b3f955191b53a78075ed2c9387ea8bee12f111
|
||||
resolved-ref: f0b3f955191b53a78075ed2c9387ea8bee12f111
|
||||
url: "https://github.com/jonsamwell/dart_gherkin.git"
|
||||
source: git
|
||||
version: "1.1.10"
|
||||
|
|
|
@ -27,7 +27,7 @@ dependencies:
|
|||
gherkin:
|
||||
git:
|
||||
url: https://github.com/jonsamwell/dart_gherkin.git
|
||||
ref: 6db02b6553200ea498c24315dc18373a6682fe7d
|
||||
ref: f0b3f955191b53a78075ed2c9387ea8bee12f111
|
||||
# ref: code_gen_changes
|
||||
|
||||
dev_dependencies:
|
||||
|
|
Loading…
Reference in New Issue