# Mobile Testing Tutorial

# Introduction

Now that's you've setup your mobile environment, it's time to run some test!

# Prerequisites

# Creating the project

  • To create a new Gondola project click the Gondola Studio icon in VSCode, then click the Create New Project icon. Gondola Studio New Project Icon

  • Select your project's location

  • Select the [Gondola-Appium] Blank project template

  • Input your gexpenses as the name then hit Enter

  • Gondola Studio will create a folder for the project

  • Explorer will open for you to begin working on your project

TIP

When you create a new project, Gondola Studio calls the command-line tool npm -i to install the Gondola FW and download all of its required dependencies. If you have downloaded them before, don't worry if you see downloading... in the status bar. NPM copies the files from an offline cache if there is nothing that needs to be updated.

# Setting up your project

  • Make a copy of gondola.json and rename it to gondola.android.json |
  • Open gondola.android.json and set the app field to https://github.com/LogiGear/gexpenses/releases/download/v1.0/gexpenses.apk
  • Next, create another folder name src in the project root.
  • Inside the src folder, create a folder named tests

# Enabling automatic compilation

We'll write our tests using the Gondola Spreadsheet Editor, and while GSE automatically saves to TypeScript, they'll need to be compiled to JavaScript for us to run them. We can set it so that is is done automatically each time you save new changes to a test by the running the command below from the terminal:

npm run compile -- -w

# Writing your first test

In the field marked description, enter Functionality Test

# Starting TestBuilder

  1. Start your emulator or connect your device.

Tip

If you're using a real Android Device, make sure you've enabled USB debugging

  1. Start an Appium server
  1. Click the TestBuilder Icon TestBuilder icon. After starting TestBuilder the Create new session dialog will open Create a new session
    • Select gondola.android.json as the capabilities file.

# Using TestBuilder

After TestBuilder has finishing initializing, you'll see the G Expenses app on your Device Live Screen using testbuilder

  1. In the Test Cases section you should see one blank Test Case. Enter check tabs in the description field
  2. On the Device Live Screen, right click on the text in the header that say "Expenses".
  3. When the context menu appears click wait for element. For the number of seconds enter 10. You'll see a new row in the test case with this keyword and the locator information for the text

Did you know?

Gondola uses a smart wait; the number of seconds you specify with wait for element is the maximum number of seconds Gondola will wait. If the element appears sooner, Gondola will stop waiting.

  1. Now right click the header again and search for check text. Enter "Expenses" for text to check for.
  • Now that we've checked for the Expenses tab, let's check that the other tab works.
  1. Right click the dashboard tab icon dashboard icon at the bottom of the screen, and click tap.
  2. Wait for the screen to refresh and then left-click the Dashboard header and click wait for element and enter 10 seconds.
  3. Then check that the header's text says "Dashboard" Your test case should look like this:

# Saving and running your test

  1. Press the save button. Type expenses_test and press enter.
  2. After this has finished, type npm run test

# Viewing the results

After running your test the results will popup in your default browser.

TIP

By default, Gondola uses Mochawesome as test reporter, however you can use other test reporters with Gondola. Click here for more.

# Adding a Second Test Case

Now that we've checked that the different tabs exist, let's test some functionality. We'll add an expense and check that it's shown.

# Creating a new Test Case block

  1. Click the add new row button in the bottom row to create a new blank row.
  2. Enter "Test Case" in the first cell of the new row.
  3. In the description field write add expense

For our next Test Case we need to go back to the Home Tab, but we don't want to add this to the Test Case Click the Inspection/Interaction Mode button in the bottom of the Device Live Screen.

  • It should be blue Inspection mode button, click it to enter Interaction Mode
  • In Interaction mode button Interaction Mode, press the GExpenses home icon Home button in GExpenses to navigate back to the Expenses tab
  • Now we want to add actions so switch back to Inspection Mode by pressing the button again. It should turn blue Inspection mode button

# Adding and Checking an Expense

  1. Right click on the Header and use wait for element and enter 10 seconds.
  2. Right-click the + button in the top corner of the Home tab and select the tap action
  3. When the Add Expense screen appears, right-click the Description field and select wait for element, enter 10 seconds.
  4. Then right click the same Description field again and select enter and enter Coffee
  5. Now right-click on the date field and select tap
  6. When the date picker pops up, use tap to select today's date, then use tap on the the ok button.
  7. Use the enter action to enter 3.00 in the price field.
  8. Right-click the Add Expense button and select tap.
  9. After the screen refreshes you should see a list item that says Coffee with under a section labeled Today with a price that says $3.00.
  10. Right click on the list item, and select wait for element and input 10 as the number of seconds
  11. Right click on the text that says Coffee and select check text. Enter Coffee
  12. Right click on the text that says $3.00 and select check text. Enter $3.00
  13. Save the test and run it.

# Save and Run your test

  1. Press the save button.
  2. In the terminal type npm run test and hit enter
Last Updated: 4/20/2020, 7:12:30 AM