Skip to content
Willington Vega edited this page Oct 13, 2020 · 2 revisions

Facebook for WooCommerce uses Codeception and WP-Browser for testing.

Setup

The first time you want to run the test suites you should create a local configuration for Codeception, as follows:

  1. Install all dependencies

     composer install
    
  2. Create a codeception.yml file

     cp codeception.local.yml codeception.yml
    
  3. Create a .env file

     cp .dist.env .env
    
  4. Now edit the .env file and update all environment variables to match your local environment

    You'd want to run the tests on a website that you only use for running tests and make sure that the plugin repository is NOT installed directly or symlinked to the wp-content/plugins of the test website. Codeception automatically copies (and then removes) the necessary files from the plugin repo to the plugins directory on the test site (see the Copier extension configuration on codeception.yml)

  5. Prepare a database dump for the test website

    For the acceptance test suite, Codeception expects to find a database dump of the test website at tests/_data/dump.sql. A database dump generated with wp db export should work, but you can also download one that its known to work from https://cloud.skyver.ge/mXu65Kw9.

    It's good to regenerate those dumps from time to time, as mandatory database upgrades and WordPress screens asking the administrator to confirm the email address start showing up if the dump is outdated and can interfere with tests results.

Integration

You can run the test suite as follows:

php vendor/bin/codecept run integration

Acceptance

The acceptance tests requires that your machine has access to a Selenium server that can access your test website. Normally, you can run Selenium on your machine by installing https://www.npmjs.com/package/selenium-standalone.

You can run the test suite as follows:

  1. Start Selenium

     selenium-standalone start
    
  2. Run the acceptance suite

     php vendor/bin/codecept run acceptance
    
Clone this wiki locally