1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Flutter] how can we run adb.exe command inside flutter test code?

Discussão em 'Mobile' iniciado por Stack, Novembro 6, 2024 às 07:52.

  1. Stack

    Stack Membro Participativo

    I'm trying to run the adb.exe command inside flutter test code. but I'm always getting an error. is it possible to run adb.exe inside flutter test code?

    ` Future<void> runAdbCommand(List<String> arguments) async {
    final result = await Process.run('c:/Users/<user.name>/AppData/Local/Android/Sdk/platform-tools/adb.exe', arguments);
    if (result.exitCode != 0) {
    throw Exception('Failed to run adb command: ${result.stderr}');
    }
    print(result.stdout);
    }

    void main() {

    IntegrationTestWidgetsFlutterBinding.ensureInitialized();

    setUpAll() async {
    await runAdbCommand(['shell', 'pm', 'grant', 'com.package.name', 'android.permission.POST_NOTIFICATIONS']);
    }

    group('end-to-end test', () {
    testWidgets('Test App',
    (WidgetTester tester) async {

    app.main();
    })})
    }`


    I was expecting the adb.exe command to be executed. but I got this error instead: Error running adb command: ProcessException: No such file or directory Command: C:/Users/<user.name>/AppData/Local/Android/Sdk/platform-tools/adb.exe shell pm grant com.package.name android.permission.POST_NOTIFICATIONS

    Continue reading...

Compartilhe esta Página