Run Espresso in pCloudy Using Gradle

Run Espresso in pCloudy Using Gradle

By Suyash dubey | Posted on April 5, 2019 | 4 min Read

Do you know why Google has selected Gradle as the build system for Android Studio? Many Android developers work in a heterogeneous environment with different technology stacks. Gradle solves some of the hardest problems faced by the developers like how to automate the testing of apps and how to manage dependencies and variations that allow professional developers to develop variations of their app with one click. This is why pCloudy came up with a new update where you can now run Espresso with Gradle on pCloudy devices. Let’s get a brief introduction about Espresso and Gradle before we learn how to run Espresso with Gradle on pCloudy devices.

Espresso is a testing framework for Android which automatically synchronizes your test actions with the UI of your app. It also let the test wait until all the background activities have finished.

Gradle is an open source advanced build tool that allows seamless execution of tasks. It uses domain specific language and it is based on Groovy and Kotlin. It is a plugin based system so if you want to automate the task of building some package from sources then you can write the complete plugging in Java and share it with the world.

Gradle allows efficient and repeatable use of espresso and Test Orchestrator which allows automated yet fine-tuned control of the way you run your test. You can decide which specific test suites to be run to distribute the test cases across different devices. It is preferred by developers as it allows deep unit and functional testing rigs.

Power up your DevOps with Espresso and Gradle on pCloudy

You would be running Espresso on your machine using Android Studio and Gradle. However, the test would be running on pCloudy device. There is a pCloudy Espresso script that is provided by us and you need to put that espresso script in the workspace of the project. Along with the Gradle script, you will also get a config file. The gradle script will read input parameters from this config file.

Then you run Gradle to invoke the script which will upload your Application APK, test APK and other APK files to pCloudy. It would acquire a device to run your test on, it would execute those tests it will report back the status of what is happening into the Android Studio. After the test cases are run you can see the detailed reports and after that gradle script will release the device for other users to use.

There is a one-time setup that you need to do to place the gradle script in the workspace and you need to fill in the configuration file. So when you run the gradle script it will complete all the task for you and generate the report.

Steps to run Espresso with Gradle on pcloudy

1. Download the espresso starter pack from here and Unzip it
2. You will find three files,
a. pCloudy_Espresso.jar
c. build.gradle.SAMPLE
(This is a sample build.gradle that shows how to change your build.gradle to add the pCloudy Espresso jar.)
3. Copy the contents of the file build.gradle.Sample to the build.gradle file of your Android Application to register the new Gradle task and update as appropriate (see the image below)


4. Place the file in your android workspace in the same directory as your build.gradle file.

5. Update the file as guided in the comments in the file.

6. In your Android workspace run the command by typing the name of the gradle task as below.

7. Once the test execution is complete you will get a URL of the test execution report. Some fields in the report are empty right now. We will fix them in subsequent phases.

The use of gradle has made it easier to run Espresso test on pCloudy devices. We can just use the configuration file and easily run the test scripts on pCloudy devices. This will save time and effort as it further simplifies the app testing process in pCloudy.

You can watch our webinar for more information.

Related Articles:

Suyash Dubey
Suyash Dubey

Suyash is a content strategist at pCloudy. He is a frequent contributor to the world's leading mobile technology blogs and tech forums. In his spare time, you will find him reading detective novels, watching a documentary or exploring a new destination.


Leave a Reply

Can't read the image? click here to refresh

Read more Articles

September 24, 2021
How to Choose The Right Automation Testing Tool

Test automation is gradually taking over manual testing as it saves time and improves the quality of testing. Especially in the case of regression testing, automation can improve efficiency by manifold times. It is a waste of time and resources…

Learn More Arrow

September 6, 2021
Challenges in Mobile App Testing

Today, there are many smartphone users in the world and so is the popularity of mobile apps. In order to be competent, mobile apps have to be unique and provide the best user experience to increase the user base. With…

Learn More Arrow

August 9, 2021
Why is it Important to Test Your Mobile Apps on Different Devices?

The Technology involved in mobile devices is changing rapidly. Mobile phones have literally personalized the choices in our lives, experts forecast that the future devices will enable us to get much done without moving an inch or a finger. The…

Learn More Arrow

Integration of TestNG Project with pCloudy Platform

Integration of TestNG Project with pCloudy Platform

By Avinash | Posted on July 11, 2017 | 3 min Read


TestNG is a testing framework inspired from JUnit and NUnit but introducing new functionalities that make it more powerful and easier to use.

It is an open source automated testing framework; where NG of TestNG means Next Generation. TestNG is similar to JUnit, especially when testing integrated classes.

TestNG eliminates most of the limitations of the older framework and gives the developer the ability to write more flexible and powerful tests with help of easy annotations, grouping, sequencing & parameterizing.

Benefits of TestNG

There are number of benefits but from Selenium perspective, major advantages of TestNG are:

  • It gives the ability to produce HTML Reports of execution
  • Annotations made testers life easy
  • Test cases can be Grouped & Prioritized more easily
  • Parallel testing is possible
  • Generates Logs
  • Data Parameterization is possible

Architecture of the testNG framework

TestNG Framework


pCloudy platform provides single click access to real Android and IOS devices directly from your browser. Use these real Mobile Devices to click-and-perform Manual Testing and execution of Automation Testing for your App. Integrate our platform with CI for continuous Automation Testing and test your App on multiple real Mobile Devices with every change of your App.

Now it’s very much simple to integrate your existing TestNG project with pCloudy.

Architecture of the TestNG framework with pCloudy

Architecture of Testing Framework with pCloudy

Prerequisite to integrate framework:

  • TestNG Project or Download sample framework code
  • Steps to integrate:

    1. Add pCloudy connector jar in your existing project

    pCloudy Java Connector

    2. Add Controller class in existing project


    3. Add DeviceContext class in existing project

    Device Context

    4. Add a list, which contains the classes that you want to run, pCloudy username, pCloudy API key & application path in Controller class.

    Create A ListUser Authentication with pCloudySelect APK in pCloudy

    Controller class

    • contains public static void main methods.
    • helps to create dynamic testng.xml file with selected device test.
    • runs testing.xml as testng target.

    5. In TestNg class, add code to launch appium under @BeforeClass, @BeforeMethod annotation according to your project:

    @Parameters({ “myDeviceContext” })
    public void beforeClass(String myDeviceContext) throwsConnectError, IOException, InterruptedException {
    DeviceContext myContext = Controller.allDeviceContexts.get(myDeviceContext);
    try {
    myContext.driver = newAndroidDriver(myContext.endpoint, myContext.capabilities);
    } catch (Exception ex) {

    6. In TestNG class, add code to quit driver under @AfterClass, @AfterMethod annotation according to your project:

    @Parameters({ “myDeviceContext” })
    public void afterClass(String myDeviceContext) throws ConnectError, IOException {
    DeviceContext myContext = Controller.allDeviceContexts.get(myDeviceContext);


    7. In TestNG class, add code to close pCloudy appium under @AfterTest annotation according to your project:

    @Parameters({ “myDeviceContext” })
    public void afterTest(String myDeviceContext) {
    DeviceContext myContext = Controller.allDeviceContexts.get(myDeviceContext);
    try {
    } catch (ConnectError | IOException e) {

    8. Run the TestNg framework execution by running controller class as java application.

    Create support ticket; if you have any issues our expertise will help you.

    Keep Automating…


Avinash Tiwari is a thought leader, a recognized keynote speaker, and the co-founder of He has 15+ experience in Product development and Testing. He brings with him a passion for emerging technology and quick adoption, both of which have solidified his reputation as a leader in the mobile app testing field.


Leave a Reply

Can't read the image? click here to refresh

Read more Articles

August 17, 2020
Top 10 Test Automation Frameworks in 2020

We are moving toward a future where everything is going to be autonomous, fast and highly efficient. To match the pace of this fast-moving ecosystem, application delivery times will have to be accelerated, but not at the cost of quality.…

Learn More Arrow

Experience pCloudy Today

Tickmark No Credit Card Required
Tickmark Exceptional Security

Copyright All Rights Reserved © 2021