How to re-run test faster for TDD?

Running test with run-test.py takes a long time (more when you depend on some other modules).
A tryton developer told me there is a way to re-run test faster (after first run).
I think it has something to do with re-using the previous database.
I looked around on how to do this but I didn’t find how to do it.
Can this be done? How?

Most of the test time is used by creating a new database and installing the module on it. The more dependencies your module has the longer this process is.

We speedup it by saving a cache of the empty database and restoring it instead of re-creating the database.

You have to set the DB_CACHE environment variable to point to an empty directory.

For the sqlite backend it’s required to install the sqlitebck package to perform the backups. There is no extra dependency if you run your tests on the postgresql backend.

If you change the database structure or the xml data of your module you must manually delete the backup file from the DB_CACHE directory in order to recreate the database and refresh the changes.

Hope it helps.

3 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.