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
- Boekhouding
- Voorraad
- PoS
- Project
- MRP
Deze vraag is gerapporteerd
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!
Geniet je van het gesprek? Blijf niet alleen lezen, doe ook mee!
Maak vandaag nog een account aan om te profiteren van exclusieve functies en deel uit te maken van onze geweldige community!
AanmeldenGerelateerde posts | Antwoorden | Weergaven | Activiteit | |
---|---|---|---|---|
|
0
dec. 15
|
3879 | ||
|
1
jan. 23
|
3893 | ||
|
0
okt. 22
|
1515 | ||
|
0
aug. 22
|
3 | ||
|
0
dec. 21
|
51 |