Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
2 Odpowiedzi
7680 Widoki

As a QA person, i need to learn about unit testing in Odoo. My idea is to find the areas we need to do unit testing and how to isolate certain codes to perform testing. Please suggest me a good reference or a doc where i can find these info. 

We have simple guideline as below
Step 01 : Learn and Identify what to test in Unit Testing (in the technology)
Step 02 : How to isolate the particular "Code"
Step 03 : Learn How to write a unit testing for Step 02

Stuck in step 01 and 02 for version 13, 14 and 15

Awatar
Odrzuć
Najlepsza odpowiedź

Hi,
Test Cases In Odoo Python

  • Testing of our module function gives the desired output
  • Executing test for fixing the bugs
  • It is the self-testing by the developers itself to check whether the module meets the requirements of the client
  • Use for the Quality assurance of the module
  • Unit Testing - Testing a unit of the module ie a function in the module

Format For The Test Case In Odoo

  •  Need to create a directory named “tests”
  • Inside that create __init__.py file and python files.
  • The format name of the Python file should be “test_file_name.py”

 Example
     
Class TestModel(common.TransactionCase):
def test_action(self):
record = self.env[‘model.name’].create({‘field’:’value’})
record.action()
self.assertEqual(record.field,expected_field_value)

  • Unit Testing will use the model “TransactionCase”
  • In this model, the function will be run manually from top to bottom automatically.
  • And the function needs to start with “test_”
  • The records created by using the test will not be stored in our database

To Run Test
 ./odoo-bin -i module_name –test-enable -c odoo.conf
Python3.8 odoo-bin -c odoo.conf –test-tags path_of_custom_module
NOTE: The above are just the basic of the test case in python
For more please refer the below blogs and documentations

How to Write Test Case in the Odoo 16 ERP

Testing Odoo — Odoo 16.0 documentation

Chapter 12.1 Python Testing - Test Cases | Odoo 15

How to Write Test Case in the Odoo 15 ERP

Hope it helps

Awatar
Odrzuć
Najlepsza odpowiedź

You may find this section of the documentation useful:  Advanced E: Python Unit Tests — Odoo 15.0 documentation

Awatar
Odrzuć
Powiązane posty Odpowiedzi Widoki Czynność
0
paź 23
1343
0
paź 23
2217
0
lis 20
3102
1
maj 17
5778
2
paź 23
2731