[go: nahoru, domu]

Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Commit

Permalink
[e2e] Test multiple failure behavior (#2514)
Browse files Browse the repository at this point in the history
* driver test for failure behavior
  • Loading branch information
collinjackson committed Feb 11, 2020
1 parent 70d874d commit 4dc097d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/e2e/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.2.3+1

* Added a driver test for failure behavior.

## 0.2.3

* Updates `E2EPlugin` and add skeleton iOS test case `E2EIosTest`.
Expand Down
1 change: 1 addition & 0 deletions packages/e2e/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dev_dependencies:
path: ../
e2e_macos:
path: ../e2e_macos
test: any

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down
39 changes: 39 additions & 0 deletions packages/e2e/example/test_driver/failure_e2e.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:e2e/e2e.dart';

import 'package:e2e_example/main.dart';

// Tests the failure behavior of the E2EWidgetsFlutterBinding
//
// This test fails intentionally! It should be run using a test runner that
// expects failure.
void main() {
E2EWidgetsFlutterBinding.ensureInitialized();

testWidgets('success', (WidgetTester tester) async {
expect(1 + 1, 2); // This should pass
});

testWidgets('failure 1', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());

// Verify that platform version is retrieved.
expect(
find.byWidgetPredicate(
(Widget widget) =>
widget is Text && widget.data.startsWith('This should fail'),
),
findsOneWidget,
);
});

testWidgets('failure 2', (WidgetTester tester) async {
expect(1 + 1, 3); // This should fail
});
}
18 changes: 18 additions & 0 deletions packages/e2e/example/test_driver/failure_e2e_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'dart:async';

import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

Future<void> main() async {
test('fails gracefully', () async {
final FlutterDriver driver = await FlutterDriver.connect();
final String result =
await driver.requestData(null, timeout: const Duration(minutes: 1));
await driver.close();
expect(
result,
'failure',
skip: true, // https://github.com/flutter/flutter/issues/48601
);
});
}
2 changes: 1 addition & 1 deletion packages/e2e/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: e2e
description: Runs tests that use the flutter_test API as integration tests.
version: 0.2.3
version: 0.2.3+1
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e

environment:
Expand Down

0 comments on commit 4dc097d

Please sign in to comment.