Giter Site home page Giter Site logo

skyeskie / flutter_driver_helper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from qwert2603/flutter_driver_helper

0.0 0.0 0.0 128 KB

Utility for easy work with flutter_driver in UI / integration tests

Home Page: https://pub.dev/packages/flutter_driver_helper

License: Apache License 2.0

Kotlin 1.03% Swift 1.02% Objective-C 0.09% Dart 65.34% Makefile 12.74% Shell 6.16% C++ 13.61%

flutter_driver_helper's Introduction

Flutter Driver Helper

pub package

Utility for easy work with flutter_driver in UI / integration tests

Update ~2.0.0

Reconfigures package to use with integration_test. There's no way to be backwards compatible, so might just split this off to another project.

Article with description (Russian).

Advantages

  • With screens (Page Objects) we separate UI-elements from actions and can reuse these screens in several tests.
  • Also we get rid of await on every line, that was easy to forget to write.
  • Logging actions while testing

Full example is in example dir.

Example

Flutter Driver Helper has several useful utilities for writing UI / integration tests.

From Android's point of view, Flutter Driver is like Espresso, while Flutter Driver Helper acts like Kakao.

Usual Flutter Driver test looks like

final list = find.byValueKey("list");
final item42 = find.byValueKey("item_42");
final secondScreen = find.byValueKey("second_screen");

await driver.tap(secondScreen);
await driver.waitForAbsent(item42);
await driver.scrollUntilVisible(list, item42);
await driver.waitFor(item42);
await driver.tap(find.pageBack());

This may be rewritten with Flutter Driver Helper to more readable style:

class MainScreen extends BaseScreen {
  MainScreen(FlutterDriver driver) : super(driver);

  DWidget get secondScreen => dWidget('second_screen');
}

class SecondScreen extends BaseScreen {
  SecondScreen(FlutterDriver driver) : super(driver);

  DWidget get list => dWidget("list");

  DScrollItem item(int index) => dScrollItem('item_$index', list);
}

...

final mainScreen = MainScreen(driver);
final secondScreen = SecondScreen(driver);

await runTestActions([
  mainScreen.secondScreen.tap(),
  secondScreen.item(42).waitForAbsent(),
  secondScreen.item(42).scrollUntilVisible(dyScroll: -300),
  secondScreen.item(42).waitFor(),
  secondScreen.pageBack.tap(),
]);

Logging

Method runTestActions logs executed actions like this:

Running check result hasText summa = 0
Running setText 12 on field_1
Running check result hasText summa = 12
Running tap on field_2
Running take screenshot field_2_variants
Running tap on variant_4
Running check result hasText summa = 16
Running tap on button_snackbar
Running tap on variant_2
Running check result hasText summa = 5
Running scrollUntilVisible list item_42

Screenshots

For convenient screenshots making diring UI tests You can use Screenshoter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.