Introducing Shirates, a Mobile Testing Automation Tool
Tags: appium, android, ios, testautomation
Published: 2022-10-11 13:59:17

This article is an introduction of **Shirates**, a mobile testing automation tool.


## Automating tests for mobile apps

Recently, automating of software test is more and more important than ever. Of course, mobile apps too. There are many paid/free tools to automate. Appium is one of products that has received a lot of attention in open source products. I tried introducing and making use of Appium, and found that it's very functional and awesome but very difficult for the average test engineers. We need long time to master and utilize it. Since even engineers with development skills have a hard time, we think it's hard to widely spread this technology to the average test engineer unless it is easier to introduce and use.
<br>

## What is Shirates

Shirates is an OSS tool that make it easy a bit, available on GitHub.

https://github.com/ldi-github/shirates-core


Shirates has the following features.

1. Almost cross-platform useful APIs to write test code, currently supports Android and iOS platform.
2. Powerful logging and reporting
3. Flexible configuration framework to set up test environment
<br>

## Setup

Shirates is available on macOS or Windows.

See [Quickstart](https://github.com/ldi-github/shirates-core/blob/main/doc/markdown/quick-start.md) to setup.

<br>
## Getting Sample Project

- Get sample project from GitHub.
```
git clone https://github.com/wave1008/shirates-samples-practice1.git
```

- Open `Practice1` directory in Finder(or Exporer).
- Right-click `build.gradle.kts` and open with IntelliJ IDEA.
![Open with IntelliJ IDEA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/psuzrnlv09rjhqv69chd.png)
![Practice1 Project](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7n096u11j0dj3sm9obr0.png)
- Open `CalculatorTest1`.
![CalculatorTest1](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qz90wgrl5ffhoww8fusc.png)

## Test Code


![Test Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lojp8qkvkzidicvc90v.png)


<br>
## Running test

* Launch Android 12 emulator and stand by. Set language in English. Install Calculator app from Google Play Store if it is not installed.
* Right-click on test1() and select `Debug` to start executing test.


![Start test](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2h7fm15c4v3q998heje.png)



<br><br>
* After the test session finished, click link `file://...` to open in Finder(or Explorer).



![Output](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8b9oj7y718anfzsnqi6c.png)

<br><br>
* Double-click `_Report(simple).html` to open in browser.



![_Report(simple).html](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dwj7isoq4g8nxfnu2efd.png)

<br><br>
* Double-click `CalculatorTest1@a.xlsx` to open the test result in spreadsheet application.

![CalculatorTest1.xlsx](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2vj9ebveuiu50xwlbd1.png)


<br>
## Explanation of test code


![Test Code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5lojp8qkvkzidicvc90v.png)


* 8: Inherit from UITest class.
* 10: Apply `Test` annotation to test1 function to be recognized as JUnit 5 test method.
* 13: Call `scenario` function.
* 14: Call `case` function. The argument is test case number.
* 15: Call `condition` function. Precondition is implemented here.
* 18-26: Call action function. Tapping keys of Calculator is implemented here.
* 27-29: Call `expectation` function. Confirmation is implemented here.

<br>
In **Shirates**, you can write test code in simple description like this.

For more information see [shirates-core](https://github.com/ldi-github/shirates-core) in GitHub.