I have wrote unit test, that extends unittest2.TestCase (using unittest2 library). But now I cannot understand and find any information how to run. Please, help. OE version is 6.1
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project
- MRP
This question has been flagged
I found it! At first, add to __init__ of your module something like
import tests
Next, create package tests in your module. Example of it's __init__:
from . import test_hr
fast_suite = [test_hr, ]
test_hr - module in package with test classes (inherited from openerp.tests.common.TransactionCase)
Next: set in your OE config in [options] section:
test_enable = True
Finally, run tests with the following command:
openerp-server -c /path/to/config.conf -d dbname -u yourmodule --log-level=test
Have fun! Really to much undocumented condition for simple tests! I think OE developers never user it :).
I struggled somewhat myself with running test cases for odoo modules.
I created an open source shell script to run tests inside a docker container, for those interested:
https://github.com/dimitrydhondt/odoutils
It can be used in interactive mode, or in a (CI/CD) script.
Running tests
Tests are automatically run when installing or updating modules if --test-enable was enabled when starting the Odoo server.
https://www.odoo.com/documentation/15.0/developer/reference/addons/testing.html
there is a plugin for pytest that can run odoo tests. Check out this SO answer: http://stackoverflow.com/a/41862286/2498426
In short: install the plugin, create a config file, run pytest.
I have a demo database, I run openerp with --test-enable --log-level=test, I have a tests folder with an __init__.py file that import my tests files. I imported openerp.tests.common import TransactionCase and created proper tests (the name of the method begins with "test_"). However openerp do not run the tests when installing or updating.
In odoo 8 and newers versions I do the same and tests are run without any problem. What am I missing here?
Thank you!
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign upRelated Posts | Replies | Views | Activity | |
---|---|---|---|---|
|
0
Dec 15
|
3857 | ||
|
1
Jan 23
|
3865 | ||
|
0
Oct 22
|
1504 | ||
|
0
Aug 22
|
3 | ||
|
0
Dec 21
|
51 |