It is better to create small modular apps instead of single monolithic application. In Bahmni EMR we have small apps for Patient Registration, Consultation, etc. An end to end functional test covering patient registration and consultation goes through multiple apps. We needed to abstract the concept of an app in test code to increase the readability and maintainability.
The app objects are natural extension of page objects recommended for writing functional tests. An app encapsulates all pages and coarse level actions in the app.
An simple implementation of app class would be
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
The test using this simple implementation would look like
1 2 3 4 5 6 7 8 |
|
The test code is structured as
apps registration app.rb patient_page.rb visit_details_page.rb clinical app.rb patient_search_page.rb features new_patient_visit.rb framework app.rb # Base class for other apps page.rb # Base class for other pages
Nicer DSL
We are using capybara and Rspec. The lambda syntax, meta programming constructs in ruby and convention based programming allowed us to implement a DSL shown below. The complete code can be found here
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
I didn’t into details of implementing the DSL. If people are interested, I can write a part 2 of this post.