[openstack-dev] Why no test DB ?

Juergen Brendel (jbrendel) jbrendel at cisco.com
Mon Dec 10 01:34:50 UTC 2012


My guess is that it is simply more complex to use a real DB. You need to initialize the database with values that suit your test. Depending on the various dependencies, foreign keys and such, you might need to populate a large number of tables.

However, I fully agree that the resulting tests would be more thorough. In the Django world, we automatically use full databases for tests (typically sqlite DBs that are created just for the purpose of the test) and you just write your unit tests so that the necessary tables will be initialized for the needs of your test.

I think it would be great to have some tests that use a real database, no stubbing. Maybe it could be just one or two to start with, we don’t have to throw away all the tests that rely on stubbing.

Juergen


From: Matthew Sherborne [mailto:msherborne at gmail.com]
Sent: Monday, December 10, 2012 1:00 PM
To: openstack-dev at lists.openstack.org
Subject: [openstack-dev] Why no test DB ?

Why don't we create and destroy a test sqlite in memory database for the tests instead of stubbing out the DB calls ?

Pros:
More thorough testing
More straight forward testing (create records instead of whole mock structures)
Easier to create new tests, no need to stub everything out again, just use the base test DB

Cons:
Probably slower tests

Has anyone looked at this in the past ?

All comments appreciated.

Kind Regards,
Matthew Sherborne
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20121210/2657fb53/attachment.html>


More information about the OpenStack-dev mailing list