PHP Fatal error: Class 'WP_UnitTestCase' not found when trying to run test-sample

Viewed 1299

I am trying to initialize php unit testing with my wordpress plugin using phpunit. I am running xampp on windows. My xampp installation is also on my E: drive if that makes any difference. I am following along with this tutorial:

https://www.smashingmagazine.com/2017/12/automated-testing-wordpress-plugins-phpunit/

I have gotten to the part where I run

install-wp-tests.sh wordpress_test root '' localhost latest

I run that and it pops up and closes quickly, so I don't know if it is really working or not. I then try to run

phpunit tests/test-sample.php

and I get:

PHP Fatal error:  Class 'WP_UnitTestCase' not found in E:\xampp\htdocs\wp-content\plugins\SRBC\tests\test-sample.php on line 11

Fatal error: Class 'WP_UnitTestCase' not found in E:\xampp\htdocs\wp-content\plugins\SRBC\tests\test-sample.php on line 11

I assume that means the install-wp-test.sh isn't installing correctly and it is missing those classes. Any ideas?

1 Answers
Related