Turn your manual testers into automation experts Request a DemoStart testRigor Free

Open HRMS Testing

Open HRMS Testing

Open HRMS is an open-source Human Resource Management System (HRMS) software solution from Cybrosys Technologies that helps organizations manage various aspects of their HR functions, such as employee data management, recruitment, performance management, payroll management, leave management, and more. Open HRMS is built using the Python programming language and is based on the Odoo framework, which is an open-source ERP software.

Open HRMS is designed to be customizable and can be adapted to suit the specific needs of an organization. It provides various features and modules that can be configured and integrated into the existing HR processes of an organization. The software is available for free, and its source code can be accessed and modified by developers, making it a popular choice for small and medium-sized enterprises that require a cost-effective HRMS solution.

As per the testing pyramid, here’re the main testing types for forging a solid testing strategy for your Open HRMS application:

Unit testing

Unit testing involves testing individual units or components of a software application in isolation from the rest of the system. A unit can be a function, method, or class that performs a specific task within the application. Unit testing is a critical step in the software development process and is often automated using testing frameworks or libraries.

The primary goal of unit testing is to ensure that each unit of code performs as intended and to identify and isolate any defects or bugs. By testing individual units, developers can detect and fix issues early in the development process, reducing the overall cost and time required to develop and maintain the software application.

During unit testing, developers write test cases that include a set of inputs, expected outputs, and preconditions. The test cases are executed against the individual units of code, and the actual results are compared to the expected results. If the actual results match the expected results, the unit passes the test, and if not, the developer can identify and fix the issue.

There are two types of unit tests you can write for your Open HRMS application:
  • Python unit tests
  • JS unit tests

Python unit testing

Odoo provides support for testing modules using Python’s unittest library. Test modules should have a name starting with test_ and should be imported from tests/__init__.py

Below is a basic example for validating strings

import unittest

class TestStringMethods(unittest.TestCase):

  def test_upper(self):
    self.assertEqual('foo'.upper(), 'FOO')

  def test_isupper(self):
    self.assertTrue('FOO'.isupper())
    self.assertFalse('Foo'.isupper())

  def test_split(self):
    s = 'hello world'
    self.assertEqual(s.split(), ['hello', 'world'])
    # check that s.split fails when the separator is not a string
    with self.assertRaises(TypeError):
      s.split(2)

if __name__ == '__main__':
  unittest.main()

Odoo provides a number of utilities and helpers related to testing Odoo content. You can read more about it over here.

JS unit testing

The Odoo framework uses the QUnit library testing framework for JS testing. QUnit defines the concepts of tests and modules and gives us a web-based interface to execute the tests.

For example, here is how a unit test can look like:

QUnit.module('py_utils');

QUnit.test('simple arithmetic', function (assert) {
  assert.expect(2);

  var result = pyUtils.py_eval("1 + 2");
  assert.strictEqual(result, 3, "should properly evaluate sum");
  result = pyUtils.py_eval("42 % 5");
  assert.strictEqual(result, 2, "should properly evaluate modulo operator");
});

You can read more about the infrastructure and recommended test practices here.

Integration testing

Integration testing is used to determine if the functions or services of a software application are working together as intended to produce the desired output. The test cases in integration testing are designed to target scenarios involving the software application’s integration with various components such as databases, file systems, and network infrastructure.

In the case of complex systems like Open HRMS, where multiple modules are involved, each module may function correctly when tested independently. However, issues may arise when the modules are combined and work together as part of the larger system. Integration testing helps to identify and resolve such issues, ensuring that the system performs as expected and meets the required specifications. By detecting and addressing integration problems early on, integration testing can help reduce the overall cost and time required to develop and maintain the software application.

Some scenarios where integration tests are used:
  • Testing crucial read-write operations into databases.
  • Testing services by mocking HTTP calls.
  • Checking GET and POST routes, controllers, and pipelines.

Below is an example of an integration test for employee registration:

import unittest
import requests

class OpenHRMIntegrationTest(unittest.TestCase):
  def setUp(self):
    # Create a test employee record
    self.employee = {
      "name": "John Doe",
      "email": "johndoe@example.com"
    }
  
  def test_employee_registration(self):
    # Send a POST request to the employee registration endpoint with the test employee data
    response = requests.post("http://openhrm.com/api/employee", json=self.employee)
    
    # Verify that the response is successful (HTTP status code 200)
    self.assertEqual(response.status_code, 200)
    
    # Verify that the response contains the expected employee data
    user = response.json()
    self.assertEqual(user["name"], self.employee["name"])
    self.assertEqual(user["email"], self.employee["email"])
  
  def tearDown(self):
    # Clean up the test environment, such as removing test data or restoring configuration values
    pass

if __name__ == '__main__':
  unittest.main()

In Odoo, you have something called test tours that can be used for integration tests. It ensures that the JS(web client side) and Python(server side) are properly connected to each other and work together. Mentioned below is an example of what a test tour can look like:

# test_tour.py

from odoo.tests import common

class TestTour(common.SavepointCase):
  @classmethod
  def setUpClass(cls):
    super(TestTour, cls).setUpClass()
    
    # Create a tour
    cls.tour = cls.env['web_tour.tour'].create({
      'name': 'Test Tour',
      'sequence': '''
        tour:
          step
            name: Start the tour
            script: self.click('.o_menu_toggle')
            trigger: .o_menu_toggle
            help: This opens the main menu
          step
            name: Open the Configuration menu
            script: self.click('.o_menu_sections a:contains("Configuration")')
            trigger: .o_menu_sections a:contains("Configuration")
            help: This opens the Configuration menu
          step
            name: Open the Users menu
            script: self.click('.o_menu_sections a:contains("Users")')
            trigger: .o_menu_sections a:contains("Users")
            help: This opens the Users menu
      '''
    })
  
  def test_tour(self):
    # Start the tour
    self.tour.ready()
    
    # Verify that the tour steps have been executed correctly
    ...

In this example, a tour is created using the web_tour.tour model and stored in the tour variable. The sequence field of the tour contains the steps of the tour, which simulate user actions such as clicking the main menu, the configuration menu, and the user’s menu.

The test_tour method is used to start the tour and verify that the tour steps have been executed correctly. This code is part of a test case that can be run using the Odoo test runner to verify that the tour works as expected.

You can read more about it here.

End-to-end testing

End-to-end testing involves testing an application’s entire workflow from start to finish to ensure that it performs as intended and meets the requirements. End-to-end testing is also known as system testing or acceptance testing.

In end-to-end testing, testers simulate real-world scenarios, including multiple modules or components, to validate the application’s functionality, reliability, and performance. This testing method verifies that all the modules or components of the application work together as intended and that the application as a whole meets the desired quality standards.

End-to-end testing can help identify issues or defects that might be missed during unit testing or integration testing, where individual units of code or modules are tested in isolation. You can do that using the following ways:
  • Selenium-based tools
  • TestCafe
  • testRigor

Selenium-based tools

Selenium is a legacy open-source tool that is still widely used for system testing. Most tools out there that are based on Selenium tend to offer features that might benefit your project. However, each of these tools does inherit some of the drawbacks that Selenium has, though they try to overcome them.

TestCafe

TestCafe is an open-source end-to-end testing tool for web applications. It is designed to simplify the process of creating and running automated tests for web applications across different browsers and platforms.

TestCafe can be used on Windows, macOS, and Linux operating systems, and it supports various web browsers such as Google Chrome, Mozilla Firefox, and Microsoft Edge. The tool is built on top of Node.js and uses JavaScript as the scripting language, which makes it easy for developers to write and maintain test scripts.

TestCafe provides several features and tools to simplify the testing process, including automatic waiting for page loads and element visibility, automatic parallel testing across multiple browsers, and built-in support for continuous integration.

testRigor

testRigor is a unique tool here since it is the only one that allows manual QA testers to build lengthy end-to-end tests. Even more so, they can do it much faster than QA engineers can write Selenium code, while spending a lot less time on test maintenance. This is possible due to testRigor’s AI engine and a handful of smart features.

You can easily test APIs, emails, SMS alerts, database records, file uploads, and identify elements on the screen and interact with them without thinking about XPaths or other element locators. testRigor also supports visual testing wherein you can directly compare screens and identify potential changes.

Let’s take a look at an example of a test case where the administrator logs in and creates a feedback record for an employee’s appraisal.

Login 
Click on "Search Menu"
Enter "Appraisal"
Click on "Appraisal"
Click on "Create" on the top left
Select "Lily Adams" from "Employee's Name"
Click on "Appraisal Deadline"
save expression "${todayDayOfMonth}" as "date"
If the stored value "date" is greater than 20 then click on "Next Month"
Save expression "(${date}-20)" as "newDate"
click stored value "newDate"
Select "Manager"
Select "Ronald Smith" from "Appraisal Reviewer"
Select "Feedback Form" from "Appraisal Form"
Click on "Start appraisal and send form"
Check that page contains "Ronald Smith" roughly below "To Start"

Besides these capabilities, testRigor also integrates with most CI/CD tools, bug tracking, and test management systems. You can read more about the capabilities of this tool here.

Conclusion

Open HRMS makes it convenient for organizations to utilize a single software for multiple tasks. You can customize the software modules as per your requirements. However, when doing so, it is necessary to have all checks and balances in place from a testing standpoint to ensure high-quality software.