Toster - Small test dsl based on adb commands that allows you to test the mobile application close to user actions

Overview

License Build

toster

Small test dsl based on adb commands that allows you to test the mobile application close to user actions

How to install

Add next fields in your root build.gradle file:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency:

dependencies {
    implementation 'by.epicbot:toster:{version}'
}

Usage

To start using Toster DSL you need to create unit tests extended from the TosterTest class and configure Config and Screens.

And just run it as usual unit-test.

From console:

./gradlew :project:test

Or from Android Studio. Don't forgot to install Kotest plugin:

Here's a full list of available functionality written using Toster:

class DemoTest : TosterTest(
   Config {
       applicationName("Samples")
       applicationPackageName("fi.epicbot.toster.samples")
       apkUrl("build/outputs/apk/debug/samples-debug.apk")
       permissions {
           grand("PERMISSION")
           grand("ANOTHER_PERMISSION")
       }
       devices {
           emulator("Pixel_3a_API_31_arm64-v8a")
           phone("123456789")
       }
       fontScaleForAll(FontScale.LARGE)
       emulatorPath("android-sdk/emulator")
       clearDataBeforeEachRun()
       runShellBeforeAllScreens("SHELL_COMMAND_BEFORE_ALL")
       runShellAfterAllScreens("SHELL_COMMAND_AFTER_ALL")
   }
   Screens{
       screen{
           name("First screen")
           url("fi.epicbot.toster.samples.SampleFontSizeActivity")
           shortUrl("SampleFontSizeActivity") // optional
           delayAfterOpenMillis(4500L)
           runShellBefore("SOME_COMMAND")
           runShellAfter("SOME_COOMAND")
           clearDataBeforeRun()
           activityParams {
               integer("int_value", 42)
               string("string_value", "42")
               long("long_value", 42L)
           }
           permissions {
               revoke("PERMISSION_1")
               grand("PERMISSION_2")
           }
           fontScale(FontScale.SMALL)
           actions {
               delay(1000L)
               click(x, y)
               swipe(SwipeMove.BottomToTop, delayMillis = 500)
               takeMemoryAllocation()
               takeScreenshot("name")
               runShell("COMMAND")
           }
       }
   }
)

Config

Application name

Set any name for your project. All output data will be in build/toster/APPLICATION_NAME

applicationName("Samples")

Application package name

Package name that you can find in manifest file.

Apk url

Path to your apk file

Permissions

You can grant some permission for the application. Toster doesn't install apk with flag -p and set them all because for some screens you can revoke them or call clear data.

In the block Config you can only grant permissions:

permissions {
   grant("PERMISSION")
   grant("ANOTHER_PERMISSION")
   ...
}

Block Screen allows grant and revoke permissions:

permissions {
   grant("PERMISSION")
   ...
   revoke("ANOTHER_PERMISSION")
   ...
}

Devices

devices {
   emulator("Pixel_3a_API_31_arm64-v8a")
   ...
   phone("123456789")
   ...
}

List of all devices that will be used on testing your app.

Id for the physical devices or emulator which can be find using adb command adb devices

Each test at the moment uses one device. No multi test run for now.

Note: You can use UUID If you have only one device.

Font scale for all

You can set up the font scale for the whole screen using the fontScale command.

Available font scales:

  • SMALL (0.85)
  • DEFAULT (1.0)
  • LARGE (1.15)
  • LARGEST (1.3)

Emulator path

Path to emulator in your sdk folder

For example, if my sdk folder

Clear data before each run

Clear application data before each run. Node that permissions also removed.

Run shell before all screens

Run shell script before all screens. For example, you can build a special flavor of your app.

Run shell after all screens

Run shell script after all screens. For example, you can send some analytics to the backend or make work on CI.

Screen

Name

Unique name for the screen.

Url

Full url for your activity including package name. Note, that aplicationPackageName can be deference

Delay after open

Set some timeout before next actions. Because the whole test system doesn't know about some callback, it's very important to set some delays between actions.

Run shell before

Same as shellBeforeAllScreens. It runs some script before this screen. For example, you can prepare some data for this screen.

Run shell after

Same as above. Runs after this screen.

Clear data before

Clear application data only before this screen.

Output reports

By default, after all tests you will get a json file with all actions that test done. It is generated with a default reporter. You can disable it, changing it in block Config -> report:

Config {
   ...
   report {
       enable(true|false)
   }
   ...
}

Or you can even add your own reporter:

Config {
   ...
   report {
       addCustomReporter(MyAwesomeReporter)
   }
   ...
}

To implement your own reporter just extends from interface Reporter:

 
class MyAwesomeReporter : Reporter {
 
   override fun makeReport(reportOutput: ReportOutput, shellExecutor: ShellExecutor) {
       // Implementation
   }
}
 

You will get raw ReportOutput with all information about screens and actions, path to all screenshots, memory measurements (if applicable) and shellExecutor if it's necessary to run some commands (save report, send somewhere to backend, etc.).

You might also like...
Test Automation of Energy Australia - Web application

Test Automation of Energy Australia - Web application Technology used - Kotlin, Java, Espresso, Android Run the test on local environment git clone ht

A powerful test framework for Android

Cafe A powerful test framework for Android named Case Automated Framework for Everyone. Home Page http://baiduqa.github.com/Cafe/ How to make Cafe dow

TestObserver to easily test LiveData and make assertions on them.
TestObserver to easily test LiveData and make assertions on them.

JCenter Update LiveData Testing is currently published on JCenter - it will serve packages until February 1st, 2022. LiveData Testing packages will be

A custom instrumentation test runner for Android that generates XML reports for integration with other tools.

Android JUnit Report Test Runner Introduction The Android JUnit report test runner is a custom instrumentation test runner for Android that creates XM

A powerful test framework for Android

Cafe A powerful test framework for Android named Case Automated Framework for Everyone. Home Page http://baiduqa.github.com/Cafe/ How to make Cafe dow

Powerful, elegant and flexible test framework for Kotlin with additional assertions, property testing and data driven testing
Powerful, elegant and flexible test framework for Kotlin with additional assertions, property testing and data driven testing

Kotest is a flexible and comprehensive testing tool for Kotlin with multiplatform support. To learn more about Kotest, visit kotest.io or see our quic

Linkester is an Android library that aims to help Android developers test their deep links implementation.
Linkester is an Android library that aims to help Android developers test their deep links implementation.

Linkester Linkester is an Android library that aims to help Android developers test their deep links implementation. The idea is to have a new launche

Strikt is an assertion library for Kotlin intended for use with a test runner such as JUnit, Minutest, Spek, or KotlinTest.

Strikt is an assertion library for Kotlin intended for use with a test runner such as JUnit, Minutest, Spek, or KotlinTest.

Barista makes developing UI test faster, easier and more predictable. Built on top of Espresso
Barista makes developing UI test faster, easier and more predictable. Built on top of Espresso

Barista makes developing UI test faster, easier and more predictable. Built on top of Espresso, it provides a simple and discoverable API, removing most of the boilerplate and verbosity of common Espresso tasks. You and your Android team will write tests with no effort.

Owner
Alexander Kulikovskiy
Alexander Kulikovskiy
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.

Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability. Often testability corresponds to go

PowerMock 3.9k Jan 5, 2023
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable.

Writing unit tests can be hard and sometimes good design has to be sacrificed for the sole purpose of testability. Often testability corresponds to go

PowerMock 3.9k Jan 2, 2023
kraskaska-runner: This application allows you to automatically restart specific command. Initially made for minecraft servers.

kraskaska-runner This application allows you to automatically restart specific command. Initially made for minecraft servers. Usage: Usage: kraskaska-

Kraskaska 2 Aug 30, 2022
Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project.

Kotlin API for React Test Renderer Kotlin wrapper for React Test Renderer, which can be used to unit test React components in a Kotlin/JS project. How

Xavier Cho 7 Jun 8, 2022
Lbc-test-app - Test Android Senior Leboncoin

Test Android Senior Leboncoin ?? Mathieu EDET Overview Min API version : 24 This

null 0 Feb 7, 2022
This is a sample API project for Rest Assured with Maven Kotlin DSL & JUnit 5

Kotlin-RestAssured Test Automation This is a sample API project for Rest Assured with Maven Kotlin DSL & JUnit 5 Introduction All the Test Cases kept

Dilshan Fernando 0 Dec 9, 2021
Selenium WebDriver and Appium based Web, Mobile (Android, iOS) and Windows desktop Automation Framework with BDD & Non-BDD implementation support

Selenium WebDriver and Appium based Web, Mobile (Android, iOS) and Windows desktop Automation Framework with BDD & Non-BDD implementation support

null 10 Dec 5, 2022
Android library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests.

Green Coffee Green Coffee is a library that allows you to run your acceptance tests written in Gherkin in your Android instrumentation tests using the

Mauricio Togneri 227 Nov 21, 2022
Turbine is a small testing library for kotlinx.coroutines Flow.

A small testing library for kotlinx.coroutines Flow

Cash App 1.8k Jan 5, 2023
Test for openbank application

openbank-test Test for openbank application Here you can find a simple test for the OpenBank application. It fetches some characters from the Marvel A

anon37894203 0 Nov 3, 2021