mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-15 07:56:11 +08:00

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.
38 lines
1005 B
Dart
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();
|
|
});
|
|
});
|
|
}
|