Files
GitJournal/test_driver/main_test.dart
Vishesh Handa 00355c532b Add a trivial integration test which just takes a screenshot
This required refactoring the code. With this we can now write an
integration test to test the main parts of the app, but more importantly
we can automate the process of generating the screenshots.
2019-02-16 00:16:32 +01:00

38 lines
1005 B
Dart

import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
void main() {
group('Test', () {
final loadedFinder = find.text('Why not add your first\n Journal Entry?');
FlutterDriver driver;
int screenshotNum = 0;
// Connect to the Flutter driver before running any tests
setUpAll(() async {
driver = await FlutterDriver.connect();
});
// Close the connection to the driver after the tests have completed
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
Future _takeScreenshot() async {
var filePath = screenshotNum.toString() + ".png";
final file = await File(filePath).create(recursive: true);
final pixels = await driver.screenshot();
await file.writeAsBytes(pixels);
}
test('Anonymous GitClone works', () async {
await driver.waitFor(loadedFinder, timeout: Duration(seconds: 5));
await _takeScreenshot();
});
});
}