Skip to content

Commit 540961a

Browse files
committed
refactor(testing): use directory target, keep generated-driver guard
The dir->file change in 17d368b was not what fixed Linux (the window-realize / ready-to-show fixes were; both the dir and file forms reported 'No tests were found' until then). Revert the flutter test target to the directory form ('integration_test') and keep only the useful part: in device mode, validate the generated integration_test/app_test.dart exists and is non-empty so a missing/empty driver surfaces as a clear error instead of a confusing 'No tests were found'.
1 parent e58afbc commit 540961a

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

sdk/python/packages/flet/src/flet/testing/flet_test_app.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -337,22 +337,25 @@ def connected() -> bool:
337337
)
338338

339339
def __flutter_test_target(self) -> str:
340-
if not self.__device_mode:
341-
return "integration_test"
342-
343-
app_test_path = (
344-
Path(self.__flutter_app_dir) / "integration_test" / "app_test.dart"
345-
)
346-
if app_test_path.is_file():
340+
# In device mode the driver (`integration_test/app_test.dart`) is
341+
# generated from the template; validate it exists and is non-empty so a
342+
# missing/empty driver surfaces as a clear error instead of a confusing
343+
# "No tests were found" from `flutter test`. The directory target is
344+
# used either way.
345+
if self.__device_mode:
346+
app_test_path = (
347+
Path(self.__flutter_app_dir) / "integration_test" / "app_test.dart"
348+
)
349+
if not app_test_path.is_file():
350+
raise RuntimeError(
351+
f"Flutter integration test driver was not generated: "
352+
f"{app_test_path}"
353+
)
347354
if not app_test_path.read_text(encoding="utf-8").strip():
348355
raise RuntimeError(
349356
f"Flutter integration test driver is empty: {app_test_path}"
350357
)
351-
return str(Path("integration_test") / "app_test.dart")
352-
353-
raise RuntimeError(
354-
f"Flutter integration test driver was not generated: {app_test_path}"
355-
)
358+
return "integration_test"
356359

357360
async def teardown(self):
358361
"""

sdk/python/packages/flet/tests/test_flet_test_app.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
from pathlib import Path
2-
31
import pytest
42

53
from flet.testing.flet_test_app import FletTestApp
64

75

8-
def test_flutter_test_target_uses_generated_app_test(tmp_path):
6+
def test_flutter_test_target_validates_generated_app_test_in_device_mode(tmp_path):
97
app_test = tmp_path / "integration_test" / "app_test.dart"
108
app_test.parent.mkdir()
119
app_test.write_text("void main() {}\n", encoding="utf-8")
1210

1311
flet_app = FletTestApp(flutter_app_dir=tmp_path, device_mode=True)
1412

15-
assert flet_app._FletTestApp__flutter_test_target() == str(
16-
Path("integration_test") / "app_test.dart"
17-
)
13+
# The directory target is used; the generated driver is only validated.
14+
assert flet_app._FletTestApp__flutter_test_target() == "integration_test"
1815

1916

2017
def test_flutter_test_target_requires_generated_app_test_in_device_mode(tmp_path):

0 commit comments

Comments
 (0)