-
Notifications
You must be signed in to change notification settings - Fork 2
/
widget_test.dart
60 lines (43 loc) · 1.91 KB
/
widget_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2018 Andrious Solutions Ltd. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
/// Show clause is used for you to appreciate what is used in the testing.
import 'package:example/src/view.dart' show MyApp, UniqueKey;
import 'package:flutter_test/flutter_test.dart'
show WidgetTester, tearDownAll, testWidgets;
import 'package:integration_test/integration_test.dart'
show IntegrationTestWidgetsFlutterBinding;
import '../integration_test/_test_example_app.dart'
show integrationTesting, resetPage1Count;
import '_unit_testing.dart' show unitTesting;
import 'test_listener.dart' show testsStateListener01;
void main() => testMyApp();
/// Also called in package's own testing file, test/widget_test.dart
void testMyApp() {
//
final app = MyApp(key: UniqueKey());
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
/// Registers a function to be run once after all tests.
/// Be sure the close the app after all the testing.
tearDownAll(() {});
testWidgets(
'test mvc_pattern',
(WidgetTester tester) async {
// Tells the tester to build a UI based on the widget tree passed to it
await tester.pumpWidget(app);
/// Flutter won’t automatically rebuild your widget in the test environment.
/// Use pump() or pumpAndSettle() to ask Flutter to rebuild the widget.
/// pumpAndSettle() waits for all animations to complete.
await tester.pumpAndSettle();
/// Tests Listener class
await testsStateListener01(tester);
/// Preform integration first to set up
/// WidgetsBinding.instance is IntegrationTestWidgetsFlutterBinding
await integrationTesting(tester);
/// Reset the counter to zero on Page 1
await resetPage1Count(tester);
/// Testing the StateMVC, ControllerMVC, and ListenerMVC
await unitTesting(tester);
},
);
}