This question has been flagged
4 Replies
10223 Views

According to the documentation, I created tests package and added some demo tests. But I cant see their execution. Simply this is what I have done.

my_module

     |------

     tests

            __init__.py

           test_my_test.py


Code in test_my_test.py

from openerp.tests import common

class TestStringMethods(common.TransactionCase):

        def setup(self):

                   print ("executing setup . . .")

                   super(TestStringMethods, self).setUp()

        def test_upper(self):

                   print ("executing test upper. . . ")

                   self.assertEqual('foo'.upper(), 'FOO')


In the __init__.py I imported test_my_test and imported tests in main __init__.py

Also added --test-enable parameter in run script.

When updating module, I can't see the execution of these test methods on console

Avatar
Discard
Best Answer

-i module_being_tested -d being_used_to_test --test-enable

Avatar
Discard
Best Answer

Just to update this post if someone is looking for a quick testing setup

dd subdirectory in working module called tests and appropriate __init__.py files. Each test files will have test_model_name.py. Using the Model TransactionCase will allow you to create temporary instances of models that will be cleaned up after execution. There will be a setUpClass function and a tearDownClass function if needed.

Example Test Setup

from odoo.tests import common, TransactionCase class TestClass(TransactionCase): @classmethod def setUpClass(cls): super().setUpClass() cls.var_one = 'One' cls.var_two = 'Two' @classmethod def tearDownClass(cls): super().tearDownClass() cls.var_one = '' cls.var_two = '' def test_case_name(self): pass



Basic Command line structure

odoo-bin -c configuration_file --log-level=test --test-tags /target_module --stop

Avatar
Discard
Best Answer

I tried to make test driven development for odoo a little bit easier with this open source script:

https://github.com/dimitrydhondt/odoutils

Perhaps it makes life slightly more pleasant ;-)

Avatar
Discard