def METHOD_NAME(
    client: Client, request: pytest.FixtureRequest
) -> Generator[None, None, None]:
    test_ui = request.config.getoption("ui")
    if not test_ui:
        yield
        return
    record_text_layout = request.config.getoption("record_text_layout")
    testcase = TestCase.build(client, request)
    testcase.dir.mkdir(exist_ok=True, parents=True)
    # remove previous files
    shutil.rmtree(testcase.actual_dir, ignore_errors=True)
    testcase.actual_dir.mkdir()
    try:
        client.debug.start_recording(str(testcase.actual_dir))
        if record_text_layout:
            client.debug.set_screen_text_file(testcase.screen_text_file)
            client.debug.watch_layout(True)
        yield
    finally:
        client.ensure_open()
        # Wait for response to Initialize, which gives the emulator time to catch up
        # and redraw the homescreen. Otherwise there's a race condition between that
        # and stopping recording.
        if record_text_layout:
            client.debug.set_screen_text_file(None)
            client.debug.watch_layout(False)
        client.init_device()
        client.debug.stop_recording()
    result = testcase.build_result(request)
    if test_ui == "record":
        _process_recorded(result)
    else:
        _process_tested(result)