Skill

Automate Odoo Testing with Python Unit and Integration Tests

Generate Odoo TransactionCase and HttpCase automated tests with the exact odoo-bin CLI command to run them.

Works with odoo

79
Spark score
out of 100
Updated last month
Version 13.1.1

Add to Favorites

Why it matters

Streamline your Odoo development by automating the creation and execution of robust unit and integration tests. Ensure code quality and stability with a comprehensive testing framework.

Outcomes

What it gets done

01

Write TransactionCase unit tests for Odoo models.

02

Develop HttpCase integration tests for Odoo controllers.

03

Configure and run tests within CI pipelines.

04

Generate boilerplate test code for faster development.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-odoo-automated-tests | bash

Overview

Odoo Automated Tests

An Odoo skill generating TransactionCase and HttpCase test code with setup/teardown/assertions, plus the matching odoo-bin CLI command. Use it when writing Odoo unit or HTTP tests, debugging CI test failures, or setting up automated test execution.

What it does

This skill generates automated test code for Odoo custom modules, built on Odoo's unittest-based testing framework. Mention @odoo-automated-tests and describe the feature you want covered, and it produces a complete test class with setup, teardown, and assertions, plus the exact odoo CLI command needed to run it. It covers three test types: TransactionCase unit tests for business logic, HttpCase integration tests for controller endpoints, and JavaScript tour tests (at a high level only). Tests are tagged @tagged('post_install', '-at_install') so they run only after all modules are installed, and shared test data is set up once per class via setUpClass() rather than re-initialized per test method with setUp() - a significant performance difference on large suites.

When to use - and when NOT to

Use it when writing unit tests for a custom Odoo model's business logic, creating an HTTP test to verify a controller endpoint responds and redirects correctly, debugging test failures inside a CI pipeline, or setting up automated test execution with --test-enable.

Do not rely on it for JavaScript tour tests in depth - those require a running browser (PhantomJS or headless Chrome) plus a live Odoo server, which this skill does not cover. HttpCase tests are significantly slower than TransactionCase tests, so reserve them for controller/route verification rather than general business-logic checks. It also does not cover mocking external services such as an SMTP server or payment gateway, and test isolation only happens at the transaction level - tests that explicitly commit data via cr.commit() can leak state between test runs.

Inputs and outputs

Input: a natural-language description of the Odoo feature or endpoint to test. Output: complete Python test class code (TransactionCase or HttpCase) with setup/teardown/assertions, and the matching odoo-bin CLI invocation to execute it - either the whole module, a specific tag, or a single test class:

./odoo-bin --test-enable --stop-after-init -d my_database -u hospital_management
./odoo-bin --test-enable --stop-after-init -d my_database --test-tags hospital_management
./odoo-bin --test-enable --stop-after-init -d my_database --test-tags /hospital_management:TestHospitalPatient

Integrations

Builds on Odoo's native testing framework (odoo.tests.common.TransactionCase, HttpCase, and the @tagged decorator), and generates commands for the standard odoo-bin CLI so tests can be wired into CI pipelines.

Who it's for

Odoo developers writing or maintaining custom modules who need reliable, isolated automated tests - especially teams enforcing test coverage in CI who want tests to follow the framework's own performance and isolation conventions (setUpClass over setUp, with_user() over sudo() for access-control checks, dedicated test databases only).

Source README

Odoo has a built-in testing framework based on Python's unittest. This skill helps you write TransactionCase unit tests, HttpCase integration tests, and JavaScript tour tests. It also covers running tests in CI pipelines.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.