앱 단위·화면·통합 테스트
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:integration_test/integration_test_driver_extended.dart';
|
||||
|
||||
/// 구현 확인물 캡처 드라이버 — 화면마다 PNG 하나를 `build/captures/` 에 떨어뜨린다.
|
||||
///
|
||||
/// 드라이버는 호스트 VM 에서 도는 별개 프로그램이라 `--dart-define` 이 닿지 않는다.
|
||||
/// 그래서 경로를 인자로 받지 않고 빌드 산출물 폴더에 모은 뒤 밖에서 옮긴다.
|
||||
///
|
||||
/// ```
|
||||
/// export ANDROID_HOME=/opt/homebrew/share/android-commandlinetools
|
||||
/// adb shell input keyevent KEYCODE_WAKEUP # ← 이거 빼먹으면 앱이 죽는다
|
||||
/// fvm flutter drive --driver=test_driver/capture_driver.dart \
|
||||
/// --target=integration_test/capture_f2_test.dart -d emulator-5554
|
||||
/// ```
|
||||
///
|
||||
/// **화면을 먼저 깨워야 한다.** 잠긴 에뮬레이터에서는 창에 surface 가 없어
|
||||
/// `takeScreenshot` 이 `PixelCopy … Window doesn't have a backing surface!` 로
|
||||
/// **앱을 죽인다.** 드라이버는 그때 `DriverError: Service has disappeared` 만
|
||||
/// 남기므로 원인이 화면 잠금이라는 게 로그에 드러나지 않는다 — logcat 을 봐야 나온다.
|
||||
Future<void> main() => integrationDriver(
|
||||
onScreenshot: (String name, List<int> bytes, [Map<String, Object?>? _]) async {
|
||||
final file = File('build/captures/$name.png');
|
||||
file.parent.createSync(recursive: true);
|
||||
file.writeAsBytesSync(bytes);
|
||||
stdout.writeln('[capture] ${file.path}');
|
||||
return true;
|
||||
},
|
||||
);
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:integration_test/integration_test_driver.dart';
|
||||
|
||||
/// 프레임 타이밍 결과를 파일로 떨어뜨리는 드라이버.
|
||||
///
|
||||
/// 기본 드라이버는 요약을 콘솔에만 남긴다. 성능 리포트가 수치를 인용해야 하므로
|
||||
/// 원본 JSON 을 남겨 근거를 되짚을 수 있게 한다.
|
||||
Future<void> main() => integrationDriver(
|
||||
responseDataCallback: (data) async {
|
||||
if (data == null) return;
|
||||
final dir = Directory('build/perf')..createSync(recursive: true);
|
||||
for (final entry in data.entries) {
|
||||
final file = File('${dir.path}/${entry.key}.json');
|
||||
file.writeAsStringSync(
|
||||
const JsonEncoder.withIndent(' ').convert(entry.value),
|
||||
);
|
||||
stdout.writeln('[perf] saved ${file.path}');
|
||||
}
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user