FletTestApp
FletTestApp
#
Flet app test controller coordinates running a Python-based Flet app alongside a Flutter integration test.
This class launches the Python Flet app, starts the Flutter test process, and facilitates programmatic interaction with the app's controls for automated UI testing.
PARAMETER | DESCRIPTION |
---|---|
flutter_app_dir
|
Path to the Flutter app directory containing integration tests.
TYPE:
|
flet_app_main
|
A callable or coroutine function representing the main entry point
of the Flet app under test. This will be invoked with an
TYPE:
|
assets_dir
|
Path to the directory containing static assets for the Flet app.
Defaults to
TYPE:
|
test_path
|
Path to the Python test file. Used to determine the location for golden screenshot comparisons.
TYPE:
|
tcp_port
|
TCP port to run the Flet server on. If not specified, a free port is automatically selected.
TYPE:
|
test_platform
|
Target platform for the Flutter integration test
(e.g.,
TYPE:
|
test_device
|
Target device ID or name for the Flutter integration test.
Env override:
TYPE:
|
capture_golden_screenshots
|
If
TYPE:
|
screenshots_pixel_ratio
|
Device pixel ratio to use when capturing screenshots.
Env override:
TYPE:
|
screenshots_similarity_threshold
|
Minimum percentage similarity required for screenshot comparisons
to pass. Env override:
TYPE:
|
use_http
|
If
TYPE:
|
disable_fvm
|
If
TYPE:
|
Environment Variables
FLET_TEST_PLATFORM
: Overridestest_platform
.FLET_TEST_DEVICE
: Overridestest_device
.FLET_TEST_GOLDEN
: Enables golden screenshot capture when set to1
.FLET_TEST_SCREENSHOTS_PIXEL_RATIO
: Overridesscreenshots_pixel_ratio
.FLET_TEST_SCREENSHOTS_SIMILARITY_THRESHOLD
: Overridesscreenshots_similarity_threshold
.FLET_TEST_USE_HTTP
: Enables HTTP transport when set to1
.FLET_TEST_DISABLE_FVM
: Disablesfvm
usage when set to1
.
screenshots_pixel_ratio
#
screenshots_pixel_ratio = float(
getenv(
"FLET_TEST_SCREENSHOTS_PIXEL_RATIO",
screenshots_pixel_ratio,
)
)
screenshots_similarity_threshold
#
screenshots_similarity_threshold = float(
getenv(
"FLET_TEST_SCREENSHOTS_SIMILARITY_THRESHOLD",
screenshots_similarity_threshold,
)
)
tester
#
tester: Tester
Returns an instance of Tester
class
that programmatically interacts with page controls and the test environment.
assert_control_screenshot
#
assert_control_screenshot(
name: str,
control: Control,
pump_times: int = 0,
pump_duration: DurationValue | None = None,
)
Adds control to a clean page, takes a screenshot and compares it with
a golden copy or takes golden screenshot if FLET_TEST_GOLDEN=1
environment variable is set.
PARAMETER | DESCRIPTION |
---|---|
name
|
Screenshot name - will be used as a base for a screenshot filename.
TYPE:
|
control
|
Control to take a screenshot of.
TYPE:
|