290 .. warning:: |
290 .. warning:: |
291 |
291 |
292 Take care to not let the imported `AutomaticWebTest` in your test module |
292 Take care to not let the imported `AutomaticWebTest` in your test module |
293 namespace, else both your subclass *and* this parent class will be run. |
293 namespace, else both your subclass *and* this parent class will be run. |
294 |
294 |
|
295 Cache heavy database setup |
|
296 ------------------------------- |
|
297 |
|
298 Some tests suite require a complex setup of the database that takes seconds (or |
|
299 event minutes) to complete. Doing the whole setup for all individual tests make |
|
300 the whole run very slow. The ``CubicWebTC`` class offer a simple way to prepare |
|
301 specific database once for multiple tests. The `test_db_id` class attribute of |
|
302 your ``CubicWebTC`` must be set a unique identifier and the |
|
303 :meth:`pre_setup_database` class method build the cached content. As the |
|
304 :meth:`pre_setup_database` method is not grantee to be called, you must not set |
|
305 any class attribut to be used during test there. Databases for each `test_db_id` |
|
306 are automatically created if not already in cache. Clearing the cache is up to |
|
307 the user. Cache files are found in the :file:`data/database` subdirectory of your |
|
308 test directory. |
|
309 |
|
310 .. warning:: |
|
311 |
|
312 Take care to always have the same :meth:`pre_setup_database` function for all |
|
313 call with a given `test_db_id` otherwise you test will have unpredictable |
|
314 result given the first encountered one. |
|
315 |
295 Testing on a real-life database |
316 Testing on a real-life database |
296 ------------------------------- |
317 ------------------------------- |
297 |
318 |
298 The ``CubicWebTC`` class uses the `cubicweb.devtools.ApptestConfiguration` |
319 The ``CubicWebTC`` class uses the `cubicweb.devtools.ApptestConfiguration` |
299 configuration class to setup its testing environment (database driver, |
320 configuration class to setup its testing environment (database driver, |