Discussion:
[Erp5-dev] testing framework
Bartek Gorny
2006-07-31 17:34:29 UTC
Permalink
Hello

I tried to write and run a unit test for ERP5, and it doesn't seem to
work as expected. The question is, what am I doing wrong?

Here is what I've done: I followed an example of testAccounting.py,
removed everything except getBusinessTemplateList and added one dummy
test function. That's all.

I placed the test and two files (framework.py and runUnitTest.py) in a
/test subdirectory, and run it with a command "./runUnitTest.py
testMyClasses".

The problem is that the logs say that all products and business
templates are sucessfully installed, then a site with an id like
erp5_portal_dd9a9b9b5ad09b83394306ac1ff29294 is created, and then
ActivityTool starts throwing exceptions "KeyError:
'erp5_portal_dd9a9b9b5ad09b83394306ac1ff29294'", and then, because
activities do not get off the queue, the test throws RuntimeError "tic
is looping forever".

What, then, is the proper way to write and run tests?

Bartek
--
"Software is largely a service industry operating under the persistent
but unfounded delusion that it is a manufacturing industry."
Eric S.Raymond, "The Magic Cauldron"
Jerome Perrin
2006-07-31 22:35:35 UTC
Permalink
Post by Bartek Gorny
Hello
I tried to write and run a unit test for ERP5, and it doesn't seem to
work as expected. The question is, what am I doing wrong?
Here is what I've done: I followed an example of testAccounting.py,
removed everything except getBusinessTemplateList and added one dummy
test function. That's all.
I placed the test and two files (framework.py and runUnitTest.py) in a
/test subdirectory, and run it with a command "./runUnitTest.py
testMyClasses".
This is not necessary, runUnitTest will try to import your class from
Products/*/tests/ directories, thus :
$INSTANCE_HOME/Products/ERP5Type/tests/runUnitTest.py testMyClasses
is enough.
Post by Bartek Gorny
The problem is that the logs say that all products and business
templates are sucessfully installed, then a site with an id like
erp5_portal_dd9a9b9b5ad09b83394306ac1ff29294 is created, and then
'erp5_portal_dd9a9b9b5ad09b83394306ac1ff29294'", and then, because
activities do not get off the queue, the test throws RuntimeError "tic
is looping forever".
During the setUp step, an ERP5 Site is added in the test storage, then
some business templates are installed ( from getBusinessTemplateList )
but if something goes wrong during BT installation, a traceback is
printed on stdout, and execution continues; (probably this test should
just fail at this point, it's a current weakness of the framework).

So, for now, check carefully what happens during setUpERP5Site from
ERP5TypeTestCase. Some configuration mistakes in business template can
prevent a bt5 from being installed on an empty site (missing
dependencies: workflows, portal types ...)

Jerome

Loading...