Using BDD To Automate Testing Of Single Page Apps (SPA) In Clinical Trials
Sauce AI for Test Authoring: Move from purport to execution in minutes.|xBack to ResourcesBlogPosted
Sauce AI for Test Authoring: Move from purport to execution in minutes.
|
x
Blog
Using BDD To Automate Testing Of Single Page Apps (SPA) In Clinical Trials
This guest berth was pen by Raymond Ponoran and Mihai Balint from Cmed Technology.
In the last yr, we at Cmed Technology pore our technology efforts on the development of a simple-to-use yet powerful software stack for Automated Testing. Over the past twelve months we & # x27; ve exchange testing the web apps of our e-Clinical merchandise suite from a largely manual trial process to a fully automatic one.
Looking back, we think we did well: testing web apps is faster than ever and we still feature more room for improvement utilise Sauce Labs & # x27; parallel jobs and reducing the overlap in our test. Along the way, we & # x27; ve learned a lot about shaping the testing stack and improving the testability of our web apps. Our finish was to institute a setup which will stay brisk for a long time and would scale with our test needs. Working toward this goal, we chose to integrate a number of different test automation technologies, carefully selecting subsist tools that are backed up by large communities. We wanted to profit from the technical advance acquire within these communities and we are excited to give ourselves. With our stack becoming more mature and stable now, we experience that the clip is correct to start sharing our experience!
This is an introductory post in which we & # x27; ll discourse our approach in general, talk about the individual pieces, the connectedness between them, and try and touch on some key gotchas and best praxis rules that we found along the way.
A Few Facts About Our Approach and Tools
Sauce Labs
We test our e-Clinical Web Apps on the four major browser: Chrome, Firefox, Safari and Internet Explorer on Linux, Mac OS X and various adaptation of Windows as well as Apple & # x27; s wandering iOS. These days maintaining an in-house Server farm that gyrate up VMs with assorted OS and Browser combinations is dear, time consuming, and cumbersome. Using the Sauce Labs platform for cloud-based examination get these problems go forth and let us focus on chop-chop screen mobile and web apps on whichever platform we wanted our product to indorse. It makes running, debug and scaling test suites easier, saving us both time and money. Sauce Labs also lets us run trial in parallel, considerably speeding up our test suites.
Sauce Labs features such as videos and screenshots help us identify matter faster and are crucial for the auditability of our engineering process. Each software version is accompanied by certification and video that evidence grounds of testing and business control of the SDLC, both essential for releasing apps in a regulated environment.
Of course we had technical issues along the way. Who doesn & # x27; t?! For example, we found that Linux browser window are much littler than in Windows, and there were networking issues. But the Sauce Labs team support was really helpful in resolving them.
BDD With Behave & amp; Behaving
We write tests inbehave / behaving, a BDD (Behaviour Driven Development) proficiency and web application prove framework with a Gherkin-based language (similar to Cucumber, Lettuce, and Freshen) that is backed up by Python code. Below is an instance scenario (taken from the examples showcased on thebehaving website
We contribute back to the community with the exam step we develop and keep them as general as potential rather than make them app-specific so that others can gain too.
Sample Behave Code
[code] Feature: Text front
Background:
Given a browser
Scenario: Search for BDD
When I visit & amp; quot; http: //www.wikipedia.org/ & amp; quot;
And I fill in & amp; quot; search & amp; quot; with & amp; quot; BDD & amp; quot;
And I press & amp; quot; go & amp; quot;
Then I should see & amp; quot; Behavior-driven development & amp; quot; within 5 seconds
[/code]
Atlassian Tools
For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.
We use JIRAto track User Stories and Bugs as well asConfluencefor team collaboration and release certification.
Behave Pro
We write tests inBehave Pro, a JIRA plugin which allows us to link each JIRA issue to at least one Test Scenario, to manage our tests and provide requirements traceability.
We export and variation the Scenarios into Bitbucket and then finally, pass them to Sauce Labs for execution on assorted OS / Browser combinations.
Like Sauce Labs, Behave Pro & # x27; s support squad was very reactive and aid us out with the technical issues we & # x27; ve find.
FixturesOur host effectuation supports preserve and restoring to previous state. This province includes everything from database substance to user approach tokens. We use these fixity to set up our Test surroundings to a known state before running our trial.
Summary So FarAll of the above is resume in the following diagram:

Practical Behaviors That Helped To Greatly Improve The Quality & amp; Efficiency Of Our Automated Testing
We continuously evaluate and amend the testability of our Web Apps. Often this is as footling as adding CSS category or HTML IDs to elements. Then there are the other, more challenging cases, like quiz form fields that POST their values in response to blur / focus lose user events.
We survey every examination scenario to make certain that the test coverage is correct, readable, and easily understandable. We use raft of CSS and jQuery selectors and absolutely love it when these are short and say like natural language.
Any test steps that stir third-party apps (such as OAuth2 providers) we package in macro or custom BDD steps. This isolates essay suites from any changes that the 3rd company makes to their app. For instance, when Google decides to change their OAuth2 login screens.
We feature created a couple of custom BDD steps to give us macros so that sequences of steps can be reused and still direct parameters. Macros are create within our BDD feature files but like any other scenario. Each web app has it & # x27; s own library of macros which we & # x27; ve delimit in a lineament file distinct from the feature file of the trial retinue. The macro library is label with @ MACRO.
Creating Macros relies on anI define & quot; macro_name (variables) & quot;custom step as follows:
[code] @ MACRO Feature: Test macros library Scenario: Define macro When I define & quot; set_date (battleground, day, month, year) & quot; as & quot; & quot; & quot; When I set & quot; $ field .day & quot; to & quot; $ day & quot; And I set & quot; $ field .month & quot; to & quot; $ month & quot; And I set & quot; $ field .year & quot; to & quot; $ year & quot; Using Macros is as simple as an I accomplish & quot; macro_name (value) & quot; custom measure, for example: Feature: Test macros Scenario: Execute macro When I fulfil & quot; set_date (# page .field__birthdt, 19, 02, 1983) & quot; [/code]
Macros are delimitate within a “ .feature ” file on its own and are usable across all of our examination.
& quot; Migrating People & quot; To Automated Testing
We & # x27; ve discovered that dislodge citizenry & # x27; s mindsets when migrating to automated examination can be quite a challenge:
Tests are live! We feature a dedicated Test Team and we institute that they are surprised and may become discomfited when absolutely good tests start failing because developers have implemented a change in the app. Be fain and allocate time to update the tests to match the app changes as such break will happen with absolute certainty. Changes are inevitable to some degree but when these do occur, make sure you have countermeasures like macros or data-driven tables to support you in easily maintaining your tests.
Developers need to be asked to consider the testability of web apps. At first it is not natural for them to add CSS classes and IDs to HTML elements to reduce the length of CSS selectors used by tests.
Want to discover more? Leave a comment ... we appear forth to your questions and feedback!
Mihai Balint Mihai Balint is a Software Technical Lead with Cmed Technology. He is interested in software engineering and care research and has be regard in respective publicly funded projects researching package design defects and formal software spec. Recently he & # x27; s been tasked with take the design and evolution of the next-gen browser-based web covering suite that Cmed Technology is developing to support the conduct of clinical trials. mibalint @ cmedtechnology.com
Raymond Ponoran Raymond Ponoran is a Testing Proficient Lead at Cmed Technology who strives for quality and likes package that is not only well do but well tested too. He ’ s been take functional, regression, system and sanity trial runs. Ray has been work in defining essay strategies, improving processes and puppet as well as in supporting the transition from mainly manual testing through to automatically testing software with BDD. rponoran @ cmedtechnology.com
Automate This With SUSA
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.
Try SUSA FreeTest Your App Autonomously
Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.
Try SUSA Free