#flutter #dart #testing #integration-testing #flutter-web
#flutter #dart #тестирование #интеграция-тестирование #flutter-web
Вопрос:
flutter/packages/integration_test/lib/integration_test_driver.dart
/// onScreenshotcan be used to process the screenshots taken during the test. /// An example could be that this callback compares the byte array against a baseline image, /// and it returnstrueif both images are equal. /// /// As a result, returningfalsefromonScreenshot will make the test fail.
Но в flutter/ packages/integration_test/lib/integration_test_driver_extended.dart есть обратный вызов onScreenshot(), но нет параметра responseDataCallback(): хотя в обоих случаях он возвращает null после выполнения всего тестового примера. Как сделать снимок экрана с помощью пакета flutter/packages/integration_test/lib/integration_test_driver.dart, если он не содержит обратного вызова onScreenshot()?
https://github.com/flutter/flutter/issues/94881
Flutter doctor:
`C:UsersExt07696FlutterProjectssignify-bics-frontend>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.5.3, on Microsoft Windows [Version 10.0.19042.867], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
[√] Chrome - develop for the web
[√] Android Studio (version 2020.3)
[√] VS Code (version 1.62.2)
[√] Connected device (2 available)
• No issues found!``
Ответ №1:
У него есть. Вы можете использовать так:
import 'dart:io';
import 'package:flutter_driver/flutter_driver.dart';
import 'package:integration_test/integration_test_driver_extended.dart';
Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
await integrationDriver(
driver: driver,
onScreenshot: (String screenshotName, List<int> screenshotBytes) async {
final File image = File('screenshots/$screenshotName.png');
image.writeAsBytesSync(screenshotBytes);
// Return false if the screenshot is invalid.
return true;
},
);
}
Ответ №2:
Вам нужно использовать пакет ‘import’:integration_test/integration_test_driver_extended.dart’import.