| name | odoo-automated-tests |
| description | Write and run Odoo automated tests using TransactionCase, HttpCase, and browser tour tests. Covers test data setup, mocking, and CI integration. |
| type | skill |
| created | 2026-02-27T00:00:00.000Z |
| domain | software-development |
| category | frontend |
| risk | safe |
| source | self |
| tags | ["skill","software-development","frontend","odoo","automated","tests"] |
Odoo Automated Tests
Overview
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.
When to Use This Skill
- Writing unit tests for a custom model's business logic.
- Creating an HTTP test to verify a controller endpoint.
- Debugging test failures in a CI pipeline.
- Setting up automated test execution with
--test-enable.
How It Works
- Activate: Mention
@odoo-automated-tests and describe the feature to test.
- Generate: Get complete test class code with setup, teardown, and assertions.
- Run: Get the exact
odoo CLI command to execute your tests.
Examples
Example 1: TransactionCase Unit Test (Odoo 15+ pattern)
from odoo.tests.common import TransactionCase
from odoo.tests import tagged
from odoo.exceptions import ValidationError
@tagged('post_install', '-at_install')
class TestHospitalPatient(TransactionCase):
@classmethod
def setUpClass(cls):
super().setUpClass()
cls.Patient = cls.env['hospital.patient']
cls.doctor = cls.env['res.users'].browse(cls.env.uid)
def test_create_patient(self):
patient = .Patient.create({
: ,
: .doctor.,
})
.assertEqual(patient.state, )
.assertEqual(patient.name, )
():
patient = .Patient.create({: })
patient.action_confirm()
.assertEqual(patient.state, )
():
.assertRaises(ValidationError):
.Patient.create({: })
():
other_user = .env.ref()
.assertRaises(Exception):
.Patient.with_user(other_user).create({: })