Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Usage Milestone: Google Analytics Module google_analytics crossed 1,000 active installs. Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Release: GraphQL Compose Codegen 1.1.2 Minor update available for module graphql_compose_codegen (1.1.2). Release: Mapy.com 1.1.3 Minor update available for module mapycom (1.1.3). Release: Ckeditor5 entity browser 3.0.3 Minor update available for module ckeditor5_entity_browser (3.0.3). Release: Ckeditor5 entity browser 3.0.1 Minor update available for module ckeditor5_entity_browser (3.0.1). Release: Ckeditor5 entity browser 3.0.2 Minor update available for module ckeditor5_entity_browser (3.0.2). Release: Teamleader Integration 4.0.2 Minor update available for module teamleader (4.0.2). Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

Sqlite test cache

No security coverage Drupal 8–10 · not 11
View on drupal.org

This module speeds up Drupal tests by caching the results of setup methods when using SQLite as the database. It allows test setup steps to be executed only once for the entire test suite, rather than before every single test method.

Test suites are slow because they set up everything before every test method. In large projects the setup methods, especially from base classes, are called thousands of times. With Sqlite as the database the results of the setup methods can be cached and this is what this module does.

How to use it

  • Download the module. There's no need to enable it, the base class just needs to be there in the codebase.
  • Set the SIMPLETEST_DB environment variable to an sqlite file location (e.g. sqlite://localhost//dev/shm/test.sqlite - this stores the database in memory).
  • Create your test class extending SqliteCachedKernelTestBase, e.g. class MyAppTestBase extends SqliteCachedKernelTestBase.
  • Do not override the setUp method in any of your test classes that are based on SqliteCachedKernelTestBase.
  • Instead, use the two methods described below.
  • Do not call parent::setUpDatabase or parent::setUpClass in any of your test cases. The parent methods will be called automatically by the base class.
  • After changing any of the setUpDatabase methods delete the cached files (their names start with cache-). If you're using docker and the SIMPLETEST_DB is in /dev/shm then restarting the container will be enough.

setUpDatabase

Put all your installation code here, e.g. installConfig, installSchema, installEntitySchema, etc. This method will be fired only once for the whole testsuite.

Note

Don't assign values to any class properties in this method. They won't be there when the test runs.

setUpClass

This is the place for setting up the class. Things like $this->entityTypeManager = $this->container->get('entity_type.manager'); can be added here. The method is called before every test (like the regular setUp method).

Known issues

In some cases the first test in a class may fail with an error unrelated to the subject matter. That's caused by static caching in core. Adding an empty test method at the beginning of the class forces a re-load with the cached database and makes the next tests work as expected.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Aug 2025
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 1
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.5 Stable 8–10 Aug 28, 2025