OpenEMR Testing
What is OpenEMR?
OpenEMR is open-source medical practice management software that supports Electronic Medical Records (EMR). It helps healthcare organizations to record, organize, and manage patient’s health information with features like e-Prescriptions, customizable forms, medical chart tracking, note-taking capabilities, and digital document management. OpenEMR software provides a patient portal through which patients can fill the registration forms online easily, view test reports and prescriptions.
OpenEMR Technical Aspects
The server side is written in PHP and can be used in conjunction with a LAMP "stack" on any operating system with PHP support. The system can run on Windows, Linux, and MacOS. The official OpenEMR code repository was migrated from CVS to GitHub.
OpenEMR Testing
Unit Testing
Unit testing is a software testing methodology in which individual components, modules, or functions of a software application are tested in isolation. Unit testing aims to verify that each part of the software behaves as expected and meets its design specifications. This helps developers identify and fix issues, bugs, or logic errors early in the development process, which leads to more robust and reliable software.
In unit testing, developers create test cases or test scripts for each unit (function, method, or class) to validate its correctness. Test cases typically consist of input data, expected output, and the actual output generated by the unit being tested.
- Each test should validate a single piece of logical code
- Name of the methods should be self-explanatory
- Assertions should be used in methods to validate individual pieces of code working fine.
Below is a sample unit test:
<?php use PHPUnit\Framework\TestCase; class BMICalculatorTest extends TestCase { public function testCalculateBMI() { // Test cases and expected results $testCases = [ ['weight' => 70, 'height' => 1.75, 'expectedBMI' => 22.9], ['weight' => 60, 'height' => 1.60, 'expectedBMI' => 23.4], ['weight' => 80, 'height' => 1.80, 'expectedBMI' => 24.7], ]; foreach ($testCases as $testCase) { $actualBMI = calculateBMI($testCase['weight'], $testCase['height']); $this->assertEquals($testCase['expectedBMI'], $actualBMI); } } public function testCalculateBMIWithInvalidInput() { $this->expectException(InvalidArgumentException::class); calculateBMI(0, 1.75); calculateBMI(70, 0); calculateBMI(-70, 1.75); calculateBMI(70, -1.75); } }
- testCalculateBMI(): This method tests the calculateBMI() function with valid input values. It contains an array of test cases, each with weight, height, and the expected BMI value. The test asserts that the calculated BMI matches the expected value for each test case.
- testCalculateBMIWithInvalidInput(): This method tests the calculateBMI() function with invalid input values. It expects the function to throw an InvalidArgumentException when either weight or height is less than or equal to zero.
Integration Testing
Integration testing focuses on testing the interactions and interfaces between individual software application components, modules, or units. The primary goal of integration testing is to ensure that the various parts of the system work together correctly and as expected when combined. Integration testing helps identify issues related to communication, data exchange, and coordination between components that might not be evident during unit testing.
Integration testing typically follows unit testing in the software development process. While unit testing verifies the correctness of individual components in isolation, integration testing checks how these components function when combined. This ensures that the overall system behavior is correct and that data flows and interactions between components are consistent and error-free.
We can perform integration testing on API and DB layers, as well as at the user interface level (which can also be a part of E2E testing)
Sample integration test:
An example of an integration test might involve verifying the correct interaction between a patient registration form and the database. In this scenario, the integration test checks if the patient's information is correctly saved and retrieved from the database after submitting the registration form.
You can use a testing framework like PHPUnit for PHP to perform this integration test. First, create a test file named PatientRegistrationIntegrationTest.php. Suppose the application has a Patient class and a PatientRepository class responsible for handling patient data in the database.
<?php use PHPUnit\Framework\TestCase; class PatientRegistrationIntegrationTest extends TestCase { protected $patientRepository; protected function setUp(): void { // Initialize the PatientRepository $this->patientRepository = new PatientRepository(); } public function testPatientRegistration() { // Create a new patient $patient = new Patient(); $patient->setFirstName('John'); $patient->setLastName('Doe'); $patient->setDateOfBirth('1980-01-01'); $patient->setGender('Male'); // Save the patient to the database $savedPatientId = $this->patientRepository->savePatient($patient); $this->assertNotNull($savedPatientId, 'Patient ID should not be null after saving'); // Retrieve the patient from the database $retrievedPatient = $this->patientRepository->getPatientById($savedPatientId); // Verify the retrieved patient data $this->assertEquals('John', $retrievedPatient->getFirstName()); $this->assertEquals('Doe', $retrievedPatient->getLastName()); $this->assertEquals('1980-01-01', $retrievedPatient->getDateOfBirth()); $this->assertEquals('Male', $retrievedPatient->getGender()); } protected function tearDown(): void { // Clean up the test data from the database $this->patientRepository->deleteAllPatients(); } }
- Create a new Patient object and set its properties.
- Save the patient to the database using the PatientRepository.
- Retrieve the patient from the database using the saved patient ID.
- Verify that the retrieved patient's properties match the original patient's properties.
End-to-End Testing
End-to-end (E2E) testing focuses on evaluating the functionality, performance, and user experience of a complete software application or system from the user's perspective. The goal of E2E testing is to ensure that the application behaves as expected and meets the defined requirements when used in real-world scenarios. E2E testing simulates the entire user journey, from the initial interaction with the application to the outcome.
Unlike unit testing and integration testing, which focus on individual components and their interactions, E2E testing validates the entire system, including front-end user interfaces, back-end services, databases, and any third-party integrations. E2E tests are typically executed after unit and integration tests and serve as a final verification step before deploying the software to production.
- Selenium with PHPUnit
- testRigor
Selenium
You will first need to install and set up Selenium WebDriver and PHPUnit. Once you have the necessary tools installed, you can create a test file named OpenEMRUserAdditionE2ETest.php.
<?php use PHPUnit\Framework\TestCase; use Selenium\WebDriver\Remote\RemoteWebDriver; use Selenium\WebDriver\WebDriverBy; use Selenium\WebDriver\WebDriverExpectedCondition; use Selenium\WebDriver\WebDriverSelect; class OpenEMRUserAdditionE2ETest extends TestCase { protected $webDriver; protected function setUp(): void { // Set up the WebDriver connection $host = 'http://localhost:4444/wd/hub'; $this->webDriver = RemoteWebDriver::create($host, DesiredCapabilities::chrome()); } public function testAddUser() { $this->webDriver->get('http://localhost/openemr'); // Log in $usernameInput = $this->webDriver->findElement(WebDriverBy::name('authUser')); $passwordInput = $this->webDriver->findElement(WebDriverBy::name('clearPass')); $loginButton = $this->webDriver->findElement(WebDriverBy::xpath("//button[@type='submit']")); $usernameInput->sendKeys('admin'); $passwordInput->sendKeys('*****'); $loginButton->click(); // Wait for the main OpenEMR page to load $this->webDriver->wait(10, 500)->until( WebDriverExpectedCondition::titleContains('openEMR') ); // Navigate to the "Add Users" tab $addUsersTab = $this->webDriver->findElement(WebDriverBy::linkText('Add Users')); $addUsersTab->click(); // Enter user details $firstNameInput = $this->webDriver->findElement(WebDriverBy::name('fname')); $lastNameInput = $this->webDriver->findElement(WebDriverBy::name('lname')); $departmentSelect = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::name('department'))); $shiftSelect = new WebDriverSelect($this->webDriver->findElement(WebDriverBy::name('shift'))); $dobInput = $this->webDriver->findElement(WebDriverBy::name('dob')); $submitButton = $this->webDriver->findElement(WebDriverBy::xpath("//button[@type='submit']")); $firstNameInput->sendKeys('jenna'); $lastNameInput->sendKeys('smith'); $departmentSelect->selectByVisibleText('General medicine'); $shiftSelect->selectByVisibleText('Day'); $dobInput->sendKeys('09/10/1998'); $submitButton->click(); // Wait for the success message to appear $this->webDriver->wait(10, 500)->until( WebDriverExpectedCondition::textToBePresentInElement(WebDriverBy::cssSelector('.alert-success'), 'Details saved successfully') ); // Verify the success message $successMessage = $this->webDriver->findElement(WebDriverBy::cssSelector('.alert-success'))->getText(); $this->assertEquals('Details saved successfully', $successMessage); } protected function tearDown(): void { // Close the WebDriver connection $this->webDriver->quit(); } }
- Navigate to the login page.
- Enter the username and password and click the "Log In" button.
- Wait for the main OpenEMR page to load and verify that the page title contains "openEMR".
- Click the "Add Users" tab to navigate to the user addition form.
- Enter the user details, such as first name, last name, department, shift, and date of birth, in the appropriate input fields.
- Click the "Submit" button to save the user details.
- Wait for the success message to appear on the screen and verify that it contains the text "Details saved successfully".
testRigor
testRigor is an excellent choice for end-to-end testing for QA teams. It is a powerful no-code AI-driven tool, which allows users to automate lengthy functional UI tests with ease. In addition, test maintenance is virtually eliminated, saving the team countless hours and allowing them to increase test coverage quickly. (You can look into a case study of how a large company was stuck at 34% test coverage, and then got to 90% within a year.)
- Usage of plain English: Allows anyone to build and understand tests purely from an end-user's point of view, without relying on locators. This makes it easier for team members with varying technical expertise to create and maintain tests.
- Support for web testing on Desktop and Mobile: testRigor supports testing on almost all browsers and multiple operating systems, ensuring compatibility and smooth functioning of the OpenEMR application across different environments.
- API testing: Helps verify the correct functioning of APIs, which are crucial for the seamless integration of various services and components in an OpenEMR application.
- Data-driven testing: Supports testing with datasets, including data from CSVs, ensuring that the OpenEMR application can handle different types of input data correctly.
- Validation of downloaded files: Enables testing and validation of files, such as PDFs, CSVs, and Microsoft Office documents, ensuring that OpenEMR generates and handles these files correctly.
- Accessing databases: Allows testers to interact with databases, enabling them to verify data integrity and proper handling of data by the application.
- Built-in login support: Facilitates testing of authentication processes, which is essential for ensuring security and access control in the application.
- Integrations with CI platforms and infrastructure providers: testRigor integrates with popular CI platforms and infrastructure providers, such as Jenkins, CircleCI, Azure DevOps, BrowserStack, LambdaTest, and SauceLabs, enabling seamless testing within the development workflow and improving overall application quality.
enter "admin" into "Enter your username" enter "*****" into "Enter your password" press "Log In" check that page contains "openEMR" click "Add Users" tab enter "jenna" into "First Name:" enter "smith" into "Last Name:" select "General medicine" from "Department:" select "Day" from "shift" enter "09/10/1998" into "Date of birth:" click "Submit" check that page contains "Details saved successfully"
How to do End-to-end Testing with testRigor
Let us take the example of an e-commerce website that sells plants and other gardening needs. We will create end-to-end test cases in testRigor using plain English test steps.
Step 1: Log in to your testRigor app with your credentials.
Step 2: Set up the test suite for the website testing by providing the information below:
- Test Suite Name: Provide a relevant and self-explanatory name.
- Type of testing: Select from the following options: Desktop Web Testing, Mobile Web Testing, Native and Hybrid Mobile, based on your test requirements.
- URL to run test on: Provide the application URL that you want to test.
- Testing credentials for your web/mobile app to test functionality which requires user to login: You can provide the app’s user login credentials here and need not write them separately in the test steps then. The login functionality will be taken care of automatically using the keyword
login
. - OS and Browser: Choose the OS Browser combination on which you want to run the test cases.
- Number of test cases to generate using AI: If you wish, you can choose to generate test cases based on the App Description text, which works on generative AI.
Step 3: Click Create Test Suite.
On the next screen, you can let AI generate the test case based on the App Description you provided during the Test Suite creation. However, for now, select do not generate any test, since we will write the test steps ourselves.
Step 4: To create a new custom test case yourself, click Add Custom Test Case.
Step 5: Provide the test case Description and start adding the test steps.
For the application under test, i.e., e-commerce website, we will perform below test steps:
- Search for a product
- Add it to the cart
- Verify that the product is present in the cart
Test Case: Search and Add to Cart
Step 1: We will add test steps on the test case editor screen one by one.
testRigor automatically navigates to the website URL you provided during the Test Suite creation. There is no need to use any separate function for it. Here is the website homepage, which we intend to test.
First, we want to search for a product in the search box. Unlike traditional testing tools, you can identify the UI element using the text you see on the screen. You need not use any CSS/XPath identifiers.
click "What are you looking for?"
Step 2: Once the cursor is in the search box, we will type the product name (lily), and press enter to start the search.
type "lily" enter enter
Search lists all products with the “lily” keyword on the webpage.
Step 3: The lily plant we are searching for needs the screen to be scrolled; for that testRigor provides a command. Scroll down until the product is present on the screen:
scroll down until page contains "Zephyranthes Lily, Rain Lily (Red)"
When the product is found on the screen, testRigor stops scrolling.
Step 4: Click on the product name to view the details:
click "Zephyranthes Lily, Rain Lily (Red)"
After the click, the product details are displayed on the screen as below, with the default Quantity as 1.
Step 5: Lets say, we want to change the Quantity to 3, so here we use the testRigor command to select from a list.
select "3" from "Quantity"
click "Add to cart"
The product is successfully added to the cart, and the “Added to your cart:” message is displayed on webpage.
Step 6: To assert that the message is successfully displayed, use a simple assertion command as below:
check that page contains "Added to your cart:"
Step 7: After this check, we will view the contents of the cart by clicking View cart as below:
click "View cart"
Step 8: Now we will again check that the product is present in the cart, under heading “Your cart” using the below assertion. With testRigor, it is really easy to specify the location of an element on the screen.
check that page contains "Zephyranthes Lily, Rain Lily (Red)" under "Your cart"
Complete Test Case
Here is how the complete test case will look in the testRigor app. The test steps are simple in plain English, enabling everyone in your team to write and execute them.
Click Add and Run.
Execution Results
Once the test is executed, you can view the execution details, such as execution status, time spent in execution, screenshots, error messages, logs, video recordings of the test execution, etc. In case of any failure, there are logs and error text that are available easily in a few clicks.
You can also download the complete execution with steps and screenshots in PDF or Word format through the View Execution option.
testRigor’s Capabilities
Apart from the simplistic test case design and execution, there are some advanced features that help you test your application using simple English commands.
- Reusable Rules (Subroutines): You can easily create functions for the test steps that you use repeatedly. You can use the Reusable Rules to create such functions and call them in test cases by simply writing their names. See the example of Reusable Rules.
- Global Variables and Data Sets: You can import data from external files or create your own global variables and data sets in testRigor to use them in data-driven testing.
- 2FA, QR Code, and Captcha Resolution: testRigor easily manages the 2FA, QR Code, and Captcha resolution through its simple English commands.
- Email, Phone Call, and SMS Testing: Use simple English commands to test the email, phone calls, and SMS. These commands are useful for validating 2FA scenarios, with OTPs and authentication codes being sent to email, phone calls, or via phone text.
- File Upload/ Download Testing: Execute the test steps involving file download or file upload without the requirement of any third-party software. You can also validate the contents of the files using testRigor’s simple English commands.
- Database Testing: Execute database queries and validate the results fetched.
testRigor enables you to test web, mobile (hybrid, native), API, and desktop apps with minimum effort and maintenance.
Additional Resources
- Access testRigor documentation to know about more useful capabilities
- Top testRigor’s features
- How to perform end-to-end testing
Conclusion
In conclusion, ensuring the quality, reliability, and security of OpenEMR applications is of paramount importance, given the critical nature of healthcare data and services. A robust testing strategy, encompassing unit, integration, and end-to-end testing, is essential for verifying individual components' proper functioning, interactions, and overall user experience.
Leveraging advanced testing tools like testRigor can significantly enhance the testing process by simplifying test creation and maintenance, supporting multiple platforms and devices, and integrating with popular CI platforms and infrastructure providers. With its natural language-based approach and extensive feature set, testRigor empowers both technical and non-technical team members to contribute effectively to the testing process, ensuring comprehensive test coverage and ultimately delivering a high-quality, reliable, and secure OpenEMR application.
By investing in a well-rounded testing strategy and leveraging state-of-the-art testing tools, healthcare organizations, and developers can effectively mitigate risks, reduce potential downtime, and ensure the delivery of a seamless, dependable, and compliant OpenEMR system that meets the diverse needs of patients, medical professionals, and administrative staff alike.
Achieve More Than 90% Test Automation | |
Step by Step Walkthroughs and Help | |
14 Day Free Trial, Cancel Anytime |