diff --git a/packages/camera/camera_android_camerax/AGENTS.md b/packages/camera/camera_android_camerax/AGENTS.md index 084feab8b2b..eff2baa79ac 100644 --- a/packages/camera/camera_android_camerax/AGENTS.md +++ b/packages/camera/camera_android_camerax/AGENTS.md @@ -23,4 +23,5 @@ - Maintain high test coverage using [dart-add-unit-test](.agents/skills/dart-add-unit-test/SKILL.md) and [dart-collect-coverage](.agents/skills/dart-collect-coverage/SKILL.md). - Avoid duplicating constant strings; reuse existing ones from adjacent code. +- **Testing Guidelines**: You MUST read and follow all rules in [TESTING.md](TESTING.md) BEFORE writing or modifying any tests. This is CRITICAL for preventing CI flakiness. - **CRITICAL**: When spawning subagents, NEVER provide absolute file paths in prompts. ALWAYS use relative paths. Passing absolute paths breaks `Workspace: branch` isolation and causes state bleed into the active workspace. diff --git a/packages/camera/camera_android_camerax/TESTING.md b/packages/camera/camera_android_camerax/TESTING.md new file mode 100644 index 00000000000..bde71885256 --- /dev/null +++ b/packages/camera/camera_android_camerax/TESTING.md @@ -0,0 +1,9 @@ +# Testing Best Practices + +This document outlines testing rules and best practices for the `camera_android_camerax` package. All contributors MUST follow these guidelines to prevent CI flakiness and maintain code quality. + +## Integration Tests + +- **Video Recording Delay**: You MUST add a delay of at least 4 seconds (e.g., `await Future.delayed(const Duration(seconds: 4));`) before stopping a video recording. + - *Why*: Both physical Android devices and emulators require time for the CameraX encoder to initialize and capture actual video frames. Stopping immediately will result in an empty or corrupted file, causing CI flakes. + - *Example*: See the `video recording state is cleared after camera is disposed` test in [`example/integration_test/integration_test.dart`](example/integration_test/integration_test.dart).