Skip to Main Content

Gray Box UI Open Source Automation Framework: Detox

Let us learn details about one of the Gray Box UI Open Source Automation Frameworks called Detox in this article
Gray Box UI Open Source automation Framework_

For a variety of reasons, automated mobile app testing has always been difficult: tests are inconsistent, we get different results depending on the device we test the app on, and we have to deal with system warnings and pop-ups informing us of system upgrades or permissions. All of this leads to the conclusion that it is more expensive to maintain tests than it is to write them.

I explored automated testing tools when I first started a new project. At the time, I was working on a React Native mobile app, and the first thing I did was research how other specialists test these types of apps. Detox seemed to be fairly trendy, and many people suggested it, so I decided to give it a try.

I would like to share everything I have learned about the tool in the following article. I will concentrate on explaining how detoxworks, how to configure it, how to write tests, and what challenges I've encountered while using detox for a mobile app.image8

So, what exactly is detox? Detox is developed by a Wix and it is a gray box E2E testing automation framework for mobile apps (Android and iOS). Detox implements JavaScript on both the server and client sides. Despite this restrictive requirement, Detox allows you to use Jest, Mocha, AVA, or any other JavaScript test runner of your choice. It runs your mobile app on real devices or simulators/emulators, interacting with it as if it were a real user.

Automation Tests

There are three types of automated tests:

  1. Unit Testing: They are used to prevent unexpected code changes and to ensure that functions perform as expected.
  2. Integration tests are in charge of ensuring that code parts and APIs are properly connected. From a technical standpoint, they test the application components as a whole.
  3. End-to-End (E2E) tests: They enable testing of the application as a whole, in its execution environment, just as a human does.So, I have one use case that describes the End-to-End testing in detox. In our product-based company, we have a mobile app called "GlideInvest" where the user has logged in and wants to navigate through the tabs .Steps are as follows:
    • Splash Screen- By Launching the app, Splash screen will get displayed.
    • Login into the app using proper credentials.
    • Navigate through Tabs below when user is logged into the system: Home --> Goals --> Funds --> Learn --> ProfileCapture1

Why Grey Box testing?

Gray box testing is a software testing technique used to test a software product or application with only a partial understanding of its internal structure. Grey box testing seeks and identifies defects caused by incorrect code structure or application use.

Detox, as a Gray Box test framework, is capable of both White and Black Box testing.

Black Box test frameworks allow us to take control of an execution context (a browser, software, mobile apps, etc.) and send control commands to it.
image5

How does Detox work?

Detox is an end-to-end testing framework. This implies that it runs your software on a real device/simulator and interacts with it in the same way that a real user would. This kind of testing can boost your app's confidence and help you automate a manual QA procedure.

When a Detox test runs, it actually has two portions operating at the same time:

  1. The actual mobile app is normally run on a simulator or emulator. On the device, a  typical native build of your app is installed and running. Before the tests begin, your app is normally built once.
  2. The test suite uses a test runner like Jest and runs on Node.js. In most cases, the tests are written in JavaScript. Because the tests are asynchronous in nature (each test line necessitates its own execution)

Detox Architecture

Detox comprises the following components:

  • Tester: The testing component that executes the test logic while running in a Node.js process on the host computer. The tester is also responsible for device management and artefact collection.
  • Detox native client (iOS and Android): A component that is seamlessly integrated into the tested app on the tested device as soon as Detox begins to execute. It syncs with the app, matches user queries, executes user commands (such as taps and scrolls), and validates expectations.
  • Detox mediator server: A small web socket server running on the host computer in a Node.js process that connects the tester and the client. Normally, the tester launches a server with a randomised session id and an open port, then passes the session and port to the client app as a launch argument.

In the next blog, I will be explaining the installation and setup in detail for the Detox framework.

Click to start searching
Recent Posts
Multi-asset allocation mutual funds: Should you invest in one scheme instead of three?
7 minsSeptember 30, 2022
Rich Dad’s Cashflow Quadrant Book Review
11 minsSeptember 27, 2022
Money frauds Online: More and More People keep falling Prey
6 minsSeptember 23, 2022
World Rowing Championship 2022: Different Investing Lessons the Sport Offers
7 minsSeptember 20, 2022
How does the core and satellite investment portfolio approach work?
7 minsSeptember 16, 2022
Posts by Categories
International Investing (3)
Glide Portfolio (3)
Tech (3)
Passive Investing (7)
Goal Planning (9)
Investment basics (10)
All Stash! (10)

Like What You See? Want to learn the simple ways to make investment stress-free?

Sign up for our newsletter & get the best expert advice & news around the financial world

We won’t annoy you more than once a week, Pinky Promise!

Multi-asset allocation mutual funds: Should you invest in one scheme instead of three?

Learn about multi-asset mutual funds and where to invest them? Learn more about multi-asset mutual funds, benefits, limitation & performance.

Rich Dad’s Cashflow Quadrant Book Review

The Cashflow Quadrant book by Rich Dad provides all the information needed to achieve financial freedom and achieve your income goals.

Money frauds Online: More and More People keep falling Prey

India and its heartland are full of bizarre stories. On the one hand, it is rich in culture and on the other, it also floats with reports of frauds and scams. People were taken by storm...