Adding unit tests
Python tests are added to addon modules by using a tests/
subdirectory. The test runner will automatically discover tests in the subdirectories with that particular name.
The tests on our todo_wizard
addon will be in a tests/test_wizard.py
file. We will need to add the tests/__init__.py
file:
from . import test_wizard
And this would be the basic skeleton for the tests/test_wizard.py
:
# -*- coding: utf-8 -*- from odoo.tests.common import TransactionCase class TestWizard(TransactionCase): def setUp(self, *args, **kwargs): super(TestWizard, self).setUp(*args, **kwargs) # Add test setup code here... def test_populate_tasks(self): "Populate tasks buttons should add two tasks" # Add test code
Odoo provides a few classes to use for tests. ...
Get Odoo 10 Development Essentials now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.