How to pass an environment variable to a flutter driver test

前端 未结 3 2280
情书的邮戳
情书的邮戳 2021-02-19 03:50

I want to pass an environment variable to a flutter drive test.

Being able to read the value in the launched application or the test code would both be fi

3条回答
  •  星月不相逢
    2021-02-19 04:00

    The .env package serves me well:

    include:

    import 'package:dotenv/dotenv.dart' show load, env;
    

    load:

    load();
    

    use:

    test('can log in', () async {
          await driver.tap(emailFieldFinder);
          await driver.enterText(env['USERNAME']);
          await driver.tap(passwordFieldFinder);
          await driver.enterText(env['PASSWORD']);
          await driver.tap(loginButtonFinder);
    
          await Future.delayed(Duration(seconds: 2));
    
          expect(await driver.getText(mainMessageFinder), "Welcome");
    });
    

提交回复
热议问题