Merge pull request #30950 from woocommerce/add/enhance-unit-test-documentation

Add troubleshooting section to running unit test section
This commit is contained in:
Néstor Soriano 2021-10-27 09:22:58 +02:00 committed by GitHub
commit 33715a6d96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 18 additions and 0 deletions

View File

@ -10,6 +10,7 @@ This document discusses unit tests. See [the e2e README](https://github.com/wooc
- [MySQL database](#mysql-database)
- [Setup instructions](#setup-instructions)
- [Running Tests](#running-tests)
- [Troubleshooting](#troubleshooting)
- [Running tests in PHP 8](#running-tests-in-php-8)
- [Writing Tests](#writing-tests)
- [Automated Tests](#automated-tests)
@ -66,6 +67,23 @@ A text code coverage summary can be displayed using the `--coverage-text` option
$ vendor/bin/phpunit --coverage-text
### Troubleshooting
In case you're unable to run the unit tests, you might see an error message similar to:
```
Fatal error: require_once(): Failed opening required '/var/folders/qr/3cnz_5_j3j1cljph_246ty1h0000gn/T/wordpress-tests-lib/includes/functions.php' (include_path='.:/usr/local/Cellar/php@7.4/7.4.23/share/php@7.4/pear') in /Users/nielslange/Plugins/woocommerce/tests/legacy/bootstrap.php on line 59
```
If you run into this problem, simply delete the WordPress test directory and run the installer again. In this particular case, you'd run the following command:
```
$ rm -rf /var/folders/qr/3cnz_5_j3j1cljph_246ty1h0000gn/T/wordpress-tests-lib
$ tests/bin/install.sh woocommerce_tests_1 root root
```
Note that `woocommerce_tests` changed to `woocommerce_tests_1` as the `woocommerce_tests` database already exists due to the prior command.
### Running tests in PHP 8
WooCommerce currently supports PHP versions from 7.0 up to 8.0, and this poses an issue with PHPUnit: