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.

To add tests for the wizard logic created in the todo_stage addon module, we can start by creating the tests/test_wizard.py file. As usual, we will also need to add the tests/__init__.py file:

from . import test_wizard 

This would be the basic skeleton for tests/test_wizard.py:

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 button should add two tasks""" # Add test ...

Get Odoo 11 Development Essentials - Third Edition 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.