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

ε祈祈猫儿з 提交于 2019-12-04 02:02:00
  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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!