Skip to content

v1: Testing framework #5479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
Aug 2, 2025
Merged

v1: Testing framework #5479

merged 71 commits into from
Aug 2, 2025

Conversation

FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Jul 24, 2025

Notes

  • This implementation is not ready for Flet users: to use by Flet team internally.

Summary by Sourcery

Add comprehensive end-to-end testing infrastructure for Flet by introducing Tester services, screenshot capture capabilities, sample integration tests in Dart and Python, and necessary build and CI updates.

New Features:

  • Add cross-platform integration testing framework with Tester and TestFinder APIs for both Dart and Python.
  • Introduce Screenshot control and services to capture widget snapshots in tests.
  • Provide Python FletTestApp utility to launch Flet apps, orchestrate Flutter integration tests, and perform SSIM-based screenshot comparisons.
  • Include sample integration tests in Dart and Python for counter, hello world, and button screenshots.

Bug Fixes:

  • Update expected control diff count in object diff in-place test.

Enhancements:

  • Enable injecting a Tester instance into FletApp to support automated widget testing.
  • Refactor control widgets to accept optional custom keys, unify key handling across platforms, and wrap screenshot keys in RepaintBoundary.
  • Adjust Python run_async and socket server logic to treat view=None as an embedded server and improve shutdown behavior.
  • Migrate Android project to Kotlin DSL, reorganize build directories, update manifest package visibility queries and permissions, and optimize JVM memory settings.

Build:

  • Convert Android Gradle build scripts to Kotlin DSL and optimize build performance.
  • Bump Gradle wrapper to 8.12 and enhance Android gradle.properties JVM args.

CI:

  • Update Appveyor configuration to run macOS integration tests, target specific Python test paths, and adjust Python wheel build jobs.

Documentation:

  • Add README for Python integration_tests detailing commands, environment variables, and golden screenshot usage.

Tests:

  • Add Dart integration_test setup using a custom FlutterWidgetTester and flutter_tester binding.
  • Add Python pytest async integration tests for end-to-end app verification and screenshot assertions.

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link

cloudflare-workers-and-pages bot commented Jul 24, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 90a5e01
Status: ✅  Deploy successful!
Preview URL: https://c0e2e944.flet-docs.pages.dev
Branch Preview URL: https://feodor-v1-tests.flet-docs.pages.dev

View logs

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a comprehensive end-to-end testing framework for the Flet project to enable automated widget testing internally by the Flet team. The framework provides unified testing APIs across both Python and Dart platforms, screenshot capture capabilities, and SSIM-based image comparison for visual regression testing.

Key Changes:

  • Added comprehensive testing infrastructure with Tester and TestFinder APIs in both Python and Dart
  • Implemented screenshot capture and comparison functionality using SSIM algorithm
  • Enhanced Android build configuration and migrated to Kotlin DSL with updated dependencies
  • Modified socket server logic to support embedded testing mode (view=None)

Reviewed Changes

Copilot reviewed 109 out of 116 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk/python/pyproject.toml Added testing dependencies (pytest_asyncio, numpy, scikit-image)
sdk/python/packages/flet/src/flet/testing/* Created Python testing framework with Tester, Finder, and FletTestApp classes
sdk/python/packages/flet/src/flet/controls/services/screenshot.py Added Screenshot service for capturing widget screenshots
sdk/python/packages/flet/src/flet/messaging/flet_socket_server.py Enhanced socket server with proper connection handling and teardown
packages/flet/lib/src/testing/* Implemented Dart testing abstractions (Tester interface, TestFinder)
packages/flet/lib/src/services/* Added Dart services for testing (TesterService, ScreenshotService)
client/android/* Migrated Android build to Kotlin DSL and updated configurations
client/integration_test/* Created Flutter integration test setup with custom tester implementation
Comments suppressed due to low confidence (1)

client/android/settings.gradle.kts:21

  • Android Gradle Plugin version 8.7.3 may not exist. The latest stable version as of my knowledge cutoff was 8.7.0. Please verify this version exists.
    id("com.android.application") version "8.7.3" apply false

@SourceryAI
Copy link

Hi @ndonkoHenri! 👋

Only authors and team members can run @sourcery-ai commands on public repos.

If you are a team member, install the @sourcery-ai bot to get access ✨

sourcery-ai[bot]
sourcery-ai bot previously requested changes Jul 30, 2025
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

Copy link
Contributor

@ndonkoHenri ndonkoHenri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@FeodorFitsner FeodorFitsner merged commit 60209c6 into main Aug 2, 2025
3 checks passed
@FeodorFitsner FeodorFitsner deleted the feodor/v1-tests branch August 2, 2025 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants