Title: Problems with codecept and wpbrowser tests
Last modified: June 14, 2023

---

# Problems with codecept and wpbrowser tests

 *  Resolved [chabekah](https://wordpress.org/support/users/chabekah/)
 * (@chabekah)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/problems-with-codecept-and-wpbrowser-tests/)
 * I am using WPBrowser ([https://wpbrowser.wptestkit.dev/](https://wpbrowser.wptestkit.dev/))
   to test the site I am working on. I have noticed that using SQLite Object Cache
   can cause my tests to fail*. This is probably as much related to the way that
   the WPBrowser testing system works as it is with your plugin (and so there may
   be little you can do about it), but whenever the plugin is installed and activated
   on my development site, then (as expected) there will be an `object-cache.php`
   and SQLite files in the `wp-content` folder. Even when I tell my tests NOT to
   activate your plugin, those files still remain in the filesystem, and are therefore
   used by the testing framework – which leads to failing tests.
 * My planned workarounds are:
    1. Manually deactivate your plugin in the wp-admin area before running my tests.
       Not ideal.
    2. Add some extra code to my testing set-up/start-up routine to delete the `object-
       cache.php` file before tests run. This is a bit of a hassle, and might cause
       me grief when I need to test how my system works with your caching plugin enabled.
 * Would you have any other suggestions on what I could do here? Is there some WP
   or SQLite Object Cache setting I can set in order to enable/disable object caching
   during testing?
 * *How does it cause my tests to fail? I’m not sure how this happens, but it looks
   like the cache gets loaded with some incorrect data (it looks like options data
   to me) at the start of the test run, which then gets repeatedly accessed from
   the cache rather than the database I am testing.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [OllieJones](https://wordpress.org/support/users/olliejones/)
 * (@olliejones)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/problems-with-codecept-and-wpbrowser-tests/#post-16819327)
 * Sorry to say I don’t know much about WPBrowser. So, I don’t know how to automate
   this process for you.
 * If you delete the .sqlite, .sqlite-wal, and .sqlite-shm files that’s the equivalent
   of flushing the cache (deleting all its entries). That might help with this situation.
 * You can, of course, use wp-cli to deactivate and reactivate the plugin. That 
   also forces a cache flush.
 * sudo -u www-data wp plugin deactivate sqlite-object-cache sudo -u www-data wp
   plugin activate sqlite-object-cache
 * When this plugin is active, avoid using wpcli with any user other than the web-
   server’s user or you can get file protection trouble.
 *  Thread Starter [chabekah](https://wordpress.org/support/users/chabekah/)
 * (@chabekah)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/problems-with-codecept-and-wpbrowser-tests/#post-16819877)
 * Thanks Ollie.
 * I actually thought of wp cli too after my post to you, but wpbrowser is a bit
   funny, and running the deactivate/activate commands within the frameworks pre/
   post hooks didn’t work, although I confess I didn’t use the `sudo -u www-data...`
   commands, and that _might _make a difference – but I wasn’t seeing any permission
   errors in the logs. TBH, I don’t really want my test scripts to require a sudo
   password.
 * In the end, I just used a PHP function to check for the presence of the `object-
   cache.php` file, and delete it before every single test with the framework’s `
   _before` hooks. It wasn’t enough just to delete it once on start-up because the
   plugin seems to recopy `object-cache.php` into `wp-content` whenever wp loads,
   and for a long-running test suite (or even if I use the dev site while the tests
   are running) then the `object-cache.php` file gets restored and my tests start
   failing from there. Not pretty, but it seems to work.
 * Thanks again, charles
 *  Plugin Author [OllieJones](https://wordpress.org/support/users/olliejones/)
 * (@olliejones)
 * [2 years, 11 months ago](https://wordpress.org/support/topic/problems-with-codecept-and-wpbrowser-tests/#post-16824521)
 * For what it’s worth, deactivating the plugin removes the object-cache.php dropin
   and deletes the .sqlite files. That’s it. Your description of your tests sounds
   like you want to run them with the object cache plugin deactivated.
 * You’re right that the plugin restores the object-cache.php dropin if it finds
   it missing.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Problems with codecept and wpbrowser tests’ is closed to new replies.

 * ![](https://ps.w.org/sqlite-object-cache/assets/icon-128x128.jpg?rev=2829632)
 * [SQLite Object Cache](https://wordpress.org/plugins/sqlite-object-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/sqlite-object-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/sqlite-object-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/sqlite-object-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/sqlite-object-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/sqlite-object-cache/reviews/)

## Tags

 * [testing](https://wordpress.org/support/topic-tag/testing/)

 * 3 replies
 * 2 participants
 * Last reply from: [OllieJones](https://wordpress.org/support/users/olliejones/)
 * Last activity: [2 years, 11 months ago](https://wordpress.org/support/topic/problems-with-codecept-and-wpbrowser-tests/#post-16824521)
 * Status: resolved