/testsweets

A utility package for TestSweets that allows you to generate and upload your automation keys for the TestSweets tool

Primary LanguageDart

Testsweets Pub Version

This package is a utility and helper package to the TestSweets product. It is the package responsible for capturing your widget keys to the database which allows us to provide the auto complete functionality when you script your test cases.

Installation

To start using the package you have to add this package to your pubspec.yaml file.

dependencies:
  ...
  testsweets: [latest_version]

Setup

After the packages have been added we have to setup the code. TestSweets makes use of Flutter Driver to drive the test cases that we write. This means we have to enable flutter driver for the version of the app that we build that goes through automation. Flutter driver disables certain things like the on screen keyboard

...

void main() {
  // 1. Setup the TestSweets internal dependencies
  await setupTestSweets();
  ...
  runApp(MyApp());
}

in your MaterialApp

...
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return MaterialApp(
      // 2. Inside MaterialApp add TestSweetsOverlayView to the builder
      //    with the projectId you get when you created a new project in Testsweets app
      builder: (context, child) => TestSweetsOverlayView(
        projectId: '3OezzTovG9xxxxxxxxx',
        child: child!,
      ),
      // 3. Finally add TestSweetsNavigatorObserver() 
      // to determine what view you are on right now
      navigatorObservers: [
        TestSweetsNavigatorObserver.instance,
      ],
    );

Capturing Interactions

To run the app in capture mode you just start the application and capture mode will be enabled. This can be turned on or off if you pass captureMode false to the TestSweetsOverlayView.

How to add an Interaction

Note: The view you are on is automatically captured

  1. Click the arrow to show the bottomsheet
  2. Select one of the three interaction types (default to Touchable)
  3. Drag the "T" icon onto the touchable widget e.g. a button
  4. Enter a widget name
  5. Tap the Save Widget button

Note: you can tap the arrow again to close the bottomsheet and move the widget freely and it will preserve the information

add.interaction.mp4

How to inspect a view

Inspecting view is the default state when you open the app

However, if you’re Creating/Editing a widget and you want to go back to inspect mode

you can tap the Clear button

How to edit an interaction

Normal Edit

  1. To start editing first you have to be in inspecting mode
  2. Long press on the widget you want to edit
  3. Choose Edit from the menu that appeared
  4. That will pop up the bottom sheet with the old content of the interaction
  5. Change name, type, and position
  6. Tap update when done
  7. If you change your mind you can tap Clear to return to inspect mode without saving
normal.edit.mp4

Quick position edit

If you want to adjust the position only, there is a shortcut

  1. Long press and hold on the interaction you want to change size
  2. While holding drag to the preferred position
  3. Lift your finger to save the current position
quick.edit.mp4

How to remove an interaction

  1. To start editing first you have to be in inspecting mode
  2. Long press on the widget you want to edit
  3. Choose Remove from the menu that appeared and that’s it!
remove.interaction.mp4

Putting the app in Drive Mode

To ensure the app is built for TestSweets to be able to drive it you you should pass --dart-define=DRIVE_MODE=true when building or running the app for TestSweets.

Build the apk

flutter build apk --debug --dart-define=DRIVE_MODE=true