What tests should a QA Engineer write for the Flutter?

dev_dependencies:
flutter_test:
sdk: flutter
void main() => runApp( MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}

class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
var _textController = TextEditingController();

@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text("Home Page"),
),
body: ListView(
children: <Widget>[
ListTile(
title: TextFormField(
key: Key('textField'),
controller: _textController,
),
),
ListTile(
title: RaisedButton(
key: Key("button"),
child: Text("Next"),
onPressed: () {
var route = MaterialPageRoute(
builder: (BuildContext context) =>
NextPage(value: _textController.text),
);
Navigator.of(context).push(route);
},
),
),
],
),
);
}
}

class NextPage extends StatefulWidget {
final String value;

NextPage({Key key, this.value}) : super(key: key);
@override
_NextPageState createState() => _NextPageState();
}

class _NextPageState extends State<NextPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Next Page"),
),
body: Text("${widget.value}"),
);
}
}
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Test form', (WidgetTester tester) async {
// CODE.
});
}
}
import 'package:flutter_test/flutter_test.dart';
import 'package:test_article/main.dart';

void main() {
testWidgets('Test form', (WidgetTester tester) async {

await tester.pumpWidget(MyApp());

});
}
import 'package:flutter_test/flutter_test.dart';
import 'package:test_article/main.dart';

void main() {
testWidgets('Test form', (WidgetTester tester) async {

await tester.pumpWidget(MyApp());

final textfield = find.byType(TextFormField);
final button = find.byType(RaisedButton);
});
}
import 'package:flutter_test/flutter_test.dart';
import 'package:test_article/main.dart';

void main() {

testWidgets('Counter increments ', (WidgetTester tester) async {

await tester.pumpWidget(MyApp());

final textfield = find.byType(TextFormField);
final button = find.byType(RaisedButton);

expect (textfield,findsOneWidget);
expect(button, findsOneWidget);

});
}
void main() {
testWidgets('Counter increments ', (WidgetTester tester) async {
await tester.pumpWidget(MyApp());
await tester.enterText(find.byKey(Key("textField")),'test');
await tester.tap(find.byType(RaisedButton));
});
}
dev_dependencies:
flutter_driver:
sdk: flutter
test: any
import 'package:flutter_driver/driver_extension.dart';
import 'package:test_article/main.dart' as app;

void main() {

enableFlutterDriverExtension();

app.main();
}
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';

void main() {
group('Counter App', () {

final textfield = find.byValueKey('textField');
final button = find.byValueKey('button');
final nextPage = find.byValueKey('nextPage');

FlutterDriver driver;

// Connect to Flutter driver before performing the test
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
// End of the driver connection after tests


test('fill the field', () async {

await driver.waitFor(textfield);
//Задержка
await waitTime();

await driver.tap(textfield);
await waitTime();

await driver.enterText('Test');
await waitTime();

await driver.tap(button);
await waitTime();
});

}, timeout: Timeout(Duration(seconds: 10)));
}
//Delays part of asynchronous function

void waitTime([int seconds = 1]) async {
await Future.delayed(Duration(seconds: seconds));
}

We are a team of rock-star developers, which provides fully-flexible and powerful products 💥.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store