Skip to content

Commit 7763799

Browse files
committed
Add some tests.
1 parent aa5de0f commit 7763799

File tree

5 files changed

+203
-1
lines changed

5 files changed

+203
-1
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ jobs:
9595
if: matrix.platform.cross == false
9696
run: cargo flutter --quiet test
9797

98+
- name: Flutter test
99+
if: matrix.platform.cross == false
100+
run: flutter test
101+
98102
lint:
99103
runs-on: ubuntu-latest
100104
steps:

lib/main.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ void main() {
99
}
1010

1111
class MyApp extends StatelessWidget {
12-
// This widget is the root of your application.
1312
@override
1413
Widget build(BuildContext context) {
1514
return MaterialApp(

pubspec.lock

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,168 @@
11
# Generated by pub
22
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
4+
archive:
5+
dependency: transitive
6+
description:
7+
name: archive
8+
url: "https://pub.dartlang.org"
9+
source: hosted
10+
version: "2.0.11"
11+
args:
12+
dependency: transitive
13+
description:
14+
name: args
15+
url: "https://pub.dartlang.org"
16+
source: hosted
17+
version: "1.5.2"
18+
async:
19+
dependency: transitive
20+
description:
21+
name: async
22+
url: "https://pub.dartlang.org"
23+
source: hosted
24+
version: "2.4.0"
25+
boolean_selector:
26+
dependency: transitive
27+
description:
28+
name: boolean_selector
29+
url: "https://pub.dartlang.org"
30+
source: hosted
31+
version: "1.0.5"
32+
charcode:
33+
dependency: transitive
34+
description:
35+
name: charcode
36+
url: "https://pub.dartlang.org"
37+
source: hosted
38+
version: "1.1.2"
439
collection:
540
dependency: transitive
641
description:
742
name: collection
843
url: "https://pub.dartlang.org"
944
source: hosted
1045
version: "1.14.11"
46+
convert:
47+
dependency: transitive
48+
description:
49+
name: convert
50+
url: "https://pub.dartlang.org"
51+
source: hosted
52+
version: "2.1.1"
53+
crypto:
54+
dependency: transitive
55+
description:
56+
name: crypto
57+
url: "https://pub.dartlang.org"
58+
source: hosted
59+
version: "2.1.3"
1160
flutter:
1261
dependency: "direct main"
1362
description: flutter
1463
source: sdk
1564
version: "0.0.0"
65+
flutter_test:
66+
dependency: "direct dev"
67+
description: flutter
68+
source: sdk
69+
version: "0.0.0"
70+
image:
71+
dependency: transitive
72+
description:
73+
name: image
74+
url: "https://pub.dartlang.org"
75+
source: hosted
76+
version: "2.1.4"
77+
matcher:
78+
dependency: transitive
79+
description:
80+
name: matcher
81+
url: "https://pub.dartlang.org"
82+
source: hosted
83+
version: "0.12.6"
1684
meta:
1785
dependency: transitive
1886
description:
1987
name: meta
2088
url: "https://pub.dartlang.org"
2189
source: hosted
2290
version: "1.1.8"
91+
path:
92+
dependency: transitive
93+
description:
94+
name: path
95+
url: "https://pub.dartlang.org"
96+
source: hosted
97+
version: "1.6.4"
98+
pedantic:
99+
dependency: transitive
100+
description:
101+
name: pedantic
102+
url: "https://pub.dartlang.org"
103+
source: hosted
104+
version: "1.8.0+1"
105+
petitparser:
106+
dependency: transitive
107+
description:
108+
name: petitparser
109+
url: "https://pub.dartlang.org"
110+
source: hosted
111+
version: "2.4.0"
112+
quiver:
113+
dependency: transitive
114+
description:
115+
name: quiver
116+
url: "https://pub.dartlang.org"
117+
source: hosted
118+
version: "2.0.5"
23119
sky_engine:
24120
dependency: transitive
25121
description: flutter
26122
source: sdk
27123
version: "0.0.99"
124+
source_span:
125+
dependency: transitive
126+
description:
127+
name: source_span
128+
url: "https://pub.dartlang.org"
129+
source: hosted
130+
version: "1.5.5"
131+
stack_trace:
132+
dependency: transitive
133+
description:
134+
name: stack_trace
135+
url: "https://pub.dartlang.org"
136+
source: hosted
137+
version: "1.9.3"
138+
stream_channel:
139+
dependency: transitive
140+
description:
141+
name: stream_channel
142+
url: "https://pub.dartlang.org"
143+
source: hosted
144+
version: "2.0.0"
145+
string_scanner:
146+
dependency: transitive
147+
description:
148+
name: string_scanner
149+
url: "https://pub.dartlang.org"
150+
source: hosted
151+
version: "1.0.5"
152+
term_glyph:
153+
dependency: transitive
154+
description:
155+
name: term_glyph
156+
url: "https://pub.dartlang.org"
157+
source: hosted
158+
version: "1.1.0"
159+
test_api:
160+
dependency: transitive
161+
description:
162+
name: test_api
163+
url: "https://pub.dartlang.org"
164+
source: hosted
165+
version: "0.2.11"
28166
typed_data:
29167
dependency: transitive
30168
description:
@@ -39,5 +177,12 @@ packages:
39177
url: "https://pub.dartlang.org"
40178
source: hosted
41179
version: "2.0.8"
180+
xml:
181+
dependency: transitive
182+
description:
183+
name: xml
184+
url: "https://pub.dartlang.org"
185+
source: hosted
186+
version: "3.5.0"
42187
sdks:
43188
dart: ">=2.6.0 <3.0.0"

pubspec.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ dependencies:
88
flutter:
99
sdk: flutter
1010

11+
dev_dependencies:
12+
flutter_test:
13+
sdk: flutter
14+
1115
flutter:
1216
assets:
1317
- assets/

test/main_test.dart

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:flutter_test/flutter_test.dart';
3+
import 'package:meta/meta.dart';
4+
5+
class MyWidget extends StatelessWidget {
6+
final String title;
7+
final String message;
8+
9+
const MyWidget({
10+
Key key,
11+
@required this.title,
12+
@required this.message,
13+
}) : super(key: key);
14+
15+
@override
16+
Widget build(BuildContext context) {
17+
return MaterialApp(
18+
title: 'Flutter Test',
19+
home: Scaffold(
20+
appBar: AppBar(
21+
title: Text(title),
22+
),
23+
body: Center(
24+
child: Text(message),
25+
),
26+
),
27+
);
28+
}
29+
}
30+
31+
void main() {
32+
group('A unit test', () {
33+
test('2 + 2 = 4', () {
34+
expect(2 + 2, 4);
35+
});
36+
});
37+
38+
group('A widget test', () {
39+
testWidgets('MyWidget has a title and message',
40+
(WidgetTester tester) async {
41+
await tester.pumpWidget(MyWidget(title: 'T', message: 'M'));
42+
43+
final titleFinder = find.text('T');
44+
final messageFinder = find.text('M');
45+
46+
expect(titleFinder, findsOneWidget);
47+
expect(messageFinder, findsOneWidget);
48+
});
49+
});
50+
}

0 commit comments

Comments
 (0)