Cucumber Framework with Appium for Android
We at Halodoc are always striving constantly towards simplifying access to Healthcare. In trying to achieve this, we make sure that the product which we are providing to the customers is the least subjected to bugs and is stable enough to provide a good user experience. To achieve this, the quality of the product should be continuously checked, which is done via our automation suite using the best of technologies.
At Halodoc, we follow BDD, and leverage the Cucumber framework using Appium for automating the testing of our Android applications. Let's dive-deep to understand each of these aspects in further detail:
BDD stands for Behaviour Driven Development which is the enhancement of TDD [Test Driven Development]. Test cases written in this approach are not only understood by the technical team but also by business stakeholders and non-techie. Since the understandability, maintenance and approach are agile in process, it is one of the best ways to implement our automation suite and bridge the gap between business stakeholders and the technical team to implement and fulfil the end-user requirements.
Why Cucumber is used when we have many other options to use BDD? Because:
- Cucumber is open source
- Cucumber supports multiple languages such as Ruby, Python, Java, C#...
- Cucumber uses Gherkin to write the test cases which can be understood and modified easily even by a non-technical user
- Cucumber reporting is easy as it has built-in plugins such as pretty, JSON, HTML, and XML which gives us a comprehensive report of test execution.
Cucumber File Structure:
- Feature File
- Step definition File
- Page File
- Runner File
Test cases for a particular requirement are grouped under a common file termed a Feature file where each test case is termed a Scenario. A scenario contains steps with annotations like Given, When and Then. There is one more annotation which we use commonly and that is And. Below is an example of How a Feature File is written with meaning for each of them.
In the above example, we see that the feature is defined and then followed with Scenario which is a test case mentioned with the Annotations where Given is pre-condition and And Helps with added steps to be done before the main action When and Then will be the result.
Step Definition File:
In this file, we will call methods for annotation steps that we mentioned in the feature file. Here we mention the annotation with @. Example: @Given, @When and @Then. Here we also mention the Cucumber Hooks such as @before and @after.
Here we define our methods to perform the specified set of tasks. We call these methods in our Step definition file. Page file also includes locators and variables.
The Runner file is the main file from where we access our feature files and run our tests. Here we would define our drivers, desired capabilities and file path. The desired capabilities include application start activity, app package, port numbers, Appium address URL, device name, platform name and so on. The path includes the feature file paths mentioned in the below format -
Appium With Cucumber
Appium is a mobile web, native, and hybrid application test automation tool. It can be used for both Android and iOS applications. We at Halodoc use Appium with Cucumber in our automation suite. To run our test cases, we need to set up the desired capabilities and initialise the Android driver along with the Appium driver. Also add certain maven dependencies in pom.xml for our test cases to run using Cucumber and Appium. Lastly, tags are used in the runner file in order to run the test cases.
It is not only convenient to use Cucumber as it is an open source tool which is widely used in the BDD approach, but also because it can be easily understood by stakeholders and reusability, along with maintenance, is simple. Appium is also an open source tool and can be integrated with ease as there is no need for any extra software to be installed on the mobile device. Both Cucumber and Appium support a wide range of languages such as Ruby, Python, Java, C#, and so on, giving the developer the freedom to write code in any language.
Scalability, reliability and maintainability are the three pillars that govern what we build at Halodoc Tech. We are actively looking for engineers at all levels and if solving hard problems with challenging requirements is your forte, please reach out to us with your resumé at firstname.lastname@example.org.
Halodoc is the number 1 all around Healthcare application in Indonesia. Our mission is to simplify and bring quality healthcare across Indonesia, from Sabang to Merauke. We connect 20,000+ doctors with patients in need through our Tele-consultation service. We partner with 3500+ pharmacies in 100+ cities to bring medicine to your doorstep. We've also partnered with Indonesia's largest lab provider to provide lab home services, and to top it off we have recently launched a premium appointment service that partners with 500+ hospitals that allow patients to book a doctor appointment inside our application. We are extremely fortunate to be trusted by our investors, such as the Bill & Melinda Gates Foundation, Singtel, UOB Ventures, Allianz, GoJek, Astra, Temasek and many more. We recently closed our Series C round and In total have raised around USD$180 million for our mission. Our team works tirelessly to make sure that we create the best healthcare solution personalised for all of our patient's needs, and are continuously on a path to simplifying healthcare for Indonesia.