- This text provides a complete overview of conducting module testing utilizing the Odoo CLI for builders.
- Earlier than beginning this tutorial, we assume that you’ve got a foundational understanding of the Command Line Interface (CLI) in Odoo. Should you lack this elementary information, it’s advisable to acquaint your self with a newbie’s information to Odoo CLI.
What’s the significance of using the Command Line Interface (CLI) for conducting Odoo testing?
Performing Odoo testing with the assistance of the Command Line Interface (CLI) provides a number of benefits:
- Automation: CLI automation streamlines varied testing duties, enabling assessments to run routinely, which saves effort and time in comparison with guide testing.
- Integration with Steady Integration (CI) Instruments: CLI integrates seamlessly with many Steady Integration (CI) instruments like Jenkins, GitLab CI/CD, and so forth., facilitating the combination of testing processes into bigger improvement pipelines.
- Headless Operation: You should utilize CLI in headless mode, which means it operates with out requiring a graphical person interface. This makes it appropriate for working assessments on servers or in environments with out a graphical interface.
- Reproducibility: CLI testing permits for constant and reproducible outcomes. Operating assessments persistently throughout totally different environments ensures dependable outcomes.
- Customization: Builders can customise check runs by specifying varied parameters and choices by means of the CLI.
Earlier than shifting forward, take a look at our Odoo improvement providers & an in depth vary of high quality Odoo Apps.
Tips on how to carry out testing utilizing Odoo CLI?
Write Checks:
- To write down assessments, create a assessments sub-package in your module.The system will routinely examine it for check modules. Take a look at modules ought to have a reputation beginning with
test_
and needs to be imported fromassessments/__init__.py
.
Instance listing construction:
your_module ├── ... ├── assessments | ├── __init__.py | ├── test_bar.py | └── test_foo.py
Contents of __init__.py
:
from . import test_foo, test_bar
Run Checks After Module Set up :
- To run assessments routinely after module set up, use the
--test-enable
flag. Right here “.” represents the present listing (the place the executable file odoo-bin is current). - “-d” or “-database” specifies the actual database you need to routinely run assessments for after module set up.
- The
--logfile=/
choice specifies the file path and title the place the Odoo server will write its log output.
Syntax:-
./odoo-bin -d cli_database --test-enable --logfile=/
Output for the above command
Run Particular Take a look at Information :
- You probably have particular check recordsdata you need to execute, use the
--test-file
choice
./odoo-bin -d cli_database --test-file addons/account/assessments/test_account_account.py
Output for the above command
Apply Take a look at Tags for Filtering :
- So if you wish to check the
stock_account
module, you should utilize:
“./odoo-bin –test-tags /stock_account” --test-tags
: This Odoo command-line choice specifies which assessments to execute. On this case, the assessments you specify after this feature are those that might be run.:TestAccountMove.test_out_invoice_auto_post_monthly,TestAccountMove.test_included_tax
: These are the check tags or labels. They’re used to categorize and establish particular assessments in Odoo. On this command, it’s telling Odoo to run two particular assessments:TestAccountMove.test_out_invoice_auto_post_monthly
: This probably refers to a particular check technique namedtest_out_invoice_auto_post_monthly
inside a category namedTestAccountMove
.TestAccountMove.test_included_tax
: Equally, this probably refers to a particular check technique namedtest_included_tax
inside a category namedTestAccountMove
.
./odoo-bin -d cli_database --test-tags :TestAccountMove.test_out_invoice_auto_post_monthly,TestAccountMove.test_included_tax
Output for the above command
Generate Screenshots of Take a look at Failures:
- When working assessments that use
HttpCase.browser_js
from the command line, the Chrome browser is utilized in headless mode. The system takes a PNG screenshot in the meanwhile of a check failure by default and writes it in ‘/tmp/odoo_tests/{db_name}/screenshots/’. - Two new command line arguments have been added since Odoo 13.0 to manage this conduct:
--screenshots
and--screencasts
- Recording a video for the check case requires the ffmpeg package deal.
“For additional particulars on Odoo testing procedures, together with superior testing methods and finest practices, please consult with the official Odoo developer documentation on testing: Odoo Testing Documentation“
NEED HELP?
Hope you discover the information useful! Please be at liberty to share your suggestions within the feedback beneath.
Should you nonetheless have any points/queries relating to the identical, please elevate a ticket on the UV Desk.
For any doubt, contact us at our help mail.