Odoo如何在IDE中调试单元测试

  1. 部署odoo测试环境(windows下见这里 )

  2. 编码测试用例,如

    foo
        -- tests
            --  __init__.py
            --  test_foo.py
    
    code in test_foo.py
    
    # -*- coding: utf-8 -*-.
    from openerp.tests.common import TransactionCase
    
    
    class MyTestCase(TransactionCase):
        def test_some_action(self):
            env = self.env['foo.ModelA']
            records = env.search([])
            for record in records:
                self.assertEqual(record.message, "test")
    
  3. 修改运行参数为:

    -c <config file path> -d <default db name> --stop-after-init --log-level=test --test-enable -i <target module name>
    
    例如:-c C:\odoo\openerp-server.conf -d odoo --stop-after-init --log-level=test --test-enable -i foo
    
  4. Finish

你可能感兴趣的:(python,openerp,odoo)