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

Odoo Testing

Odoo Testing

Odoo is an open-source suite of business applications including, among others, CRM (Customer Relationship Management), sales, project management, manufacturing, inventory management, accounting, and human resources. It’s designed to help businesses manage various aspects of their operations in an integrated and comprehensive manner.

You might have added customizations to the Odoo offerings to make it the right fit for your business process. Or you may have just integrated with existing systems in your organization. Whatever the case, you need to perform testing.

You can achieve holistic test coverage by performing testing at different levels. Odoo primarily uses Python and JavaScript, so you must pick tools and frameworks compatible with these programming languages.

Unit testing

The first level of testing is at the very base, which is closest to the code. Through unit testing, you look for the basic functioning of the various units of code, like methods, classes, or APIs. The concern is strictly to check the code at its most granular level.

Let’s look at the frameworks that are popularly used for testing Odoo.

Python unit testing

You can test your Odoo Python code using Unittest libraries. There are many classes that support unit testing, like

  • odoo.tests.TransactionCase
  • odoo.tests.SingleTransactionCase
  • odoo.tests.HttpCase
  • odoo.tests.tagged
  • odoo.tests.Form
  • odoo.tests.M2MProxy
  • odoo.tests.O2MProxy
Here’s a display of how a unit test can look like using TransactionCase.
class TestModelAB(TransactionCase):
  def test_some_action(self):
    record = self.env['model.a'].create({'field': 'value'})
    record.some_action()
    self.assertEqual(
      record.field,
      expected_field_value)

  # other tests...

JavaScript unit testing

JavaScript code can be tested using QUnit. Considering the complexity of Odoo applications, you are better off having unit tests for your JavaScript code as well.

Here’s an example of a Javascript unit test.
QUnit.test('simple group rendering', function (assert) {
  assert.expect(1);

  var form = testUtils.createView({
    View: FormView,
    model: 'partner',
    data: this.data,
    arch: '<form string="Partners">' +
      '<group>' +
        '<field name="foo"/>' +
      '</group>' +
    '</form>',
    res_id: 1,
  });
 
  assert.containsOnce(form, 'table.o_inner_group');
  form.destroy();
});

Integration testing

Checking the Python and JavaScript code by themselves is helpful, yet it doesn’t confirm that the web client and server are functioning as a unit. To check this, we could create different tests called tours.

A tour is a small representation of a business process. It describes the steps in order that one must take. Next, the test runner sets up a PhantomJs browser, directs it to the correct URL, and imitates clicking and typing as outlined in the scenario.

When it comes to JavaScript code, you need to register your tour like this:
/** @odoo-module **/
import tour from 'web_tour.tour';

tour.register('rental_product_configurator_tour', {
  url: '/web', // Here, you can specify any other starting url
  test: true,
}, [
  // Your sequence of steps
]);

Likewise, to start a tour from a Python test, make the class inherit from HTTPCase and call start_tour.

End-to-end testing

Along with unit and integration tests, you need to write end-to-end tests to make sure that all major workflows in your application work as expected. These tests are usually UI-based, spanning across modules.

Testing the whole system from start to finish can be good for finding problems that might not be seen with just unit or integration testing because these problems are about how the system acts or what the user thinks should happen.

You can find many tools in the market that help with this.

Here are a few examples.

Cypress

Cypress is a JavaScript-based testing tool that enables you to write tests that interact with a web application like a real user would. It runs tests in a real browser, providing a more accurate testing environment for user interactions, network requests, and application behavior.

However, you can find better alternatives to Cypress in the test automation market.

testRigor

You can choose testRigor instead of using tools that need coding to create tests or those record-and-playback ones that often result in unreliable tests. This tool allows you to create test steps in simple English for apps that run on different browsers and devices. Or you can use the test recorder to record your actions, and testRigor creates ultra-stable test cases in plain English from those UI actions. You can test web, mobile, API, and desktop using testRigor.

It does this and much more by using generative AI, NLP (Natural Language Processing), and ML (Machine Learning). Here’s a sample test case written in testRigor. You can see how easy it is to work with UI elements and make assertions happen in testRigor.
login
click on "Appraisal"
click on "Create" on the top left
select "Jake Jones" 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"

testRigor has a lot to offer in terms of features and capabilities. Even if you do find something lacking, you can easily integrate it with other tools and platforms. You need not worry about test maintenance, as testRigor does a great job at managing this woe as well by leveraging AI algorithms and self-healing. Thus, you can focus on creating impactful test cases peacefully.

Conclusion

Odoo is a great framework to use to manage business operations. You can make these modules operate without problems alongside your current processes by making more adjustments. Just make sure to choose intelligent testing tools that lower the amount of work you have and not add more to it.

Join the next wave of functional testing now.
A testRigor specialist will walk you through our platform with a custom demo.