fix(steps): ensured well known flutter test action timeout duration is shorter then the step timeout duration

fix(reporter): ensured summary reporter reports failure reason
This commit is contained in:
Jon Samwell 2018-11-01 19:11:33 +11:00
parent 31cbf8a07b
commit 6241b9720a
10 changed files with 35 additions and 12 deletions

View File

@ -1,3 +1,8 @@
## [0.0.10] - 01/11/2018
* Ensured summary reporter reports failure reason
* Ensured well known Flutter step actions timeout before their parent step
## [0.0.9] - 01/11/2018
* Updated example of custom parameters and how to use them

View File

@ -24,7 +24,7 @@ class ThenExpectElementToHaveValue
try {
final text = await FlutterDriverUtils.getText(
world.driver, find.byValueKey(key),
timeout: timeout);
timeout: timeout * .9);
expect(text, value);
} catch (e) {
await reporter.message(

View File

@ -12,7 +12,8 @@ class WhenFillFieldStep extends When2WithWorld<String, String, FlutterWorld> {
@override
Future<void> executeStep(String key, String input2) async {
await FlutterDriverUtils.enterText(
world.driver, find.byValueKey(key), input2);
world.driver, find.byValueKey(key), input2,
timeout: timeout * .9);
}
@override

View File

@ -18,5 +18,5 @@ class WhenPauseStep extends When1<int> {
}
@override
RegExp get pattern => RegExp(r"I pause for {int} seconds");
RegExp get pattern => RegExp(r"I pause for {int} second(s)");
}

View File

@ -25,6 +25,6 @@ class WhenTapWidget extends When1WithWorld<String, FlutterWorld> {
@override
Future<void> executeStep(String key) async {
await FlutterDriverUtils.tap(world.driver, find.byValueKey(key),
timeout: timeout);
timeout: timeout * .9);
}
}

View File

@ -1,5 +1,6 @@
import 'package:flutter_gherkin/src/gherkin/exceptions/syntax_error.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/background.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/comment_line.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/debug_information.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/empty_line.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/runnable.dart';
@ -50,6 +51,7 @@ class FeatureRunnable extends RunnableBlock {
}
break;
case EmptyLineRunnable:
case CommentLineRunnable:
break;
default:
throw new Exception(

View File

@ -27,8 +27,9 @@ class ProgressReporter extends StdoutReporter {
_getStatePrefixIcon(message.result.result),
_getNameAndContext(message.name, message.context),
_getExecutionDuration(message.result),
_getReasonMessage(message.result),
_getErrorMessage(message.result)
].join((" ")),
].join((" ")).trimRight(),
_getMessageColour(message.result.result));
}
@ -36,6 +37,14 @@ class ProgressReporter extends StdoutReporter {
// ignore messages
}
String _getReasonMessage(StepResult stepResult) {
if (stepResult.resultReason != null && stepResult.resultReason.isNotEmpty) {
return "\n ${stepResult.resultReason}";
} else {
return "";
}
}
String _getErrorMessage(StepResult stepResult) {
if (stepResult is ErroredStepResult) {
return "\n${stepResult.exception}\n${stepResult.stackTrace}";

View File

@ -1,6 +1,6 @@
name: flutter_gherkin
description: A Gherkin / Cucumber parser and test runner for Dart and Flutter
version: 0.0.9
version: 0.0.10
author: Jon Samwell <jonsamwell@gmail.com>
homepage: https://github.com/jonsamwell/flutter_gherkin

View File

@ -1,4 +1,5 @@
import 'package:flutter_gherkin/src/gherkin/runnables/background.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/comment_line.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/debug_information.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/empty_line.dart';
import 'package:flutter_gherkin/src/gherkin/runnables/feature.dart';
@ -26,6 +27,10 @@ void main() {
final runnable = new FeatureRunnable("", debugInfo);
runnable.addChild(EmptyLineRunnable(debugInfo));
});
test('can add CommentLineRunnable', () {
final runnable = new FeatureRunnable("", debugInfo);
runnable.addChild(CommentLineRunnable("", debugInfo));
});
test('can add ScenarioRunnable', () {
final runnable = new FeatureRunnable("", debugInfo);
runnable.addChild(ScenarioRunnable("1", debugInfo));

View File

@ -23,7 +23,7 @@ void main() {
await reporter.onStepFinished(StepFinishedMessage(
"Step 2",
RunnableDebugInformation("filePath", 2, "line 2"),
StepResult(0, StepExecutionResult.fail)));
StepResult(0, StepExecutionResult.fail, "Failed Reason")));
await reporter.onStepFinished(StepFinishedMessage(
"Step 3",
RunnableDebugInformation("filePath", 3, "line 3"),
@ -38,11 +38,12 @@ void main() {
StepResult(1, StepExecutionResult.timeout)));
expect(reporter.output, [
" √ Step 1 # filePath:1 took 0ms ",
" × Step 2 # filePath:2 took 0ms ",
" - Step 3 # filePath:3 took 0ms ",
" × Step 4 # filePath:4 took 0ms ",
" × Step 5 # filePath:5 took 1ms "
" √ Step 1 # filePath:1 took 0ms",
" × Step 2 # filePath:2 took 0ms \n"
" Failed Reason",
" - Step 3 # filePath:3 took 0ms",
" × Step 4 # filePath:4 took 0ms",
" × Step 5 # filePath:5 took 1ms"
]);
});