sir, i’m new in tryton i want to know how i start writing unit testcases. what are the important files required in unit testing.
The best is to look at existing example like the tests in the party module which are quite complete: http://hg.tryton.org/modules/party/file/default/tests/test_party.py
It is important to inherit from ModuleTestCase
(and set the module
attribute) and to use the decorator with_transaction
. Otherwise everything else behaves like standard Python unittest.
Our module test case defines a set of standard functions that ensure your module is correctly defined.
Here is an example of a minimum test case which only uses the ModuleTestCase to ensure everything is properly defined.
Sorry for the ignorance, but how do I run the test? It does it on the module update ?
Thanks
You can execute them with the trytond.run-tests module. This is the command:
python -m trytond.tests.run-tests -m <module_name>
It will be good if someone could add a Testing topic to the documentation.
To execute the module we use below command
python -m trytond.tests.run-tests -m <module_name> but how we can see that which line is skipped or not executed.
and what is the role of doctest and how we can write it.
In issue7685, you can see a proposal to include coverage reporting.
You can replace python setup.py test
by python -m trytond.tests.run-tests -m <module_name>
.
The doctest are scenario which uses proteus to mimic the behavior of the client. So it is higher level of testing. It is mainly used to test a complete workflow.
python -m trytond.tests.run-tests -m <module_name>
The above command only tell us that how many testcases run and in how much time. but i want to know that which line is skipped or not executed.