【发布时间】:2019-06-25 23:14:33
【问题描述】:
我正在尝试使用 phpunit 使用我的 wordpress 插件初始化 php 单元测试。我在 Windows 上运行 xampp。我的 xampp 安装也在我的 E: 驱动器上,如果这有什么不同的话。我正在关注本教程:
https://www.smashingmagazine.com/2017/12/automated-testing-wordpress-plugins-phpunit/
我已经到了我跑步的地方
install-wp-tests.sh wordpress_test root '' localhost latest
我运行它,它会快速弹出并关闭,所以我不知道它是否真的有效。然后我尝试运行
phpunit tests/test-sample.php
我得到:
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
我认为这意味着 install-wp-test.sh 没有正确安装并且缺少这些类。有什么想法吗?
【问题讨论】:
-
我运行了 bootstrap.php,它给了我这个
Could not find C:\Users\gaming\AppData\Local\Temp/wordpress-tests-lib/includes/functions.php, have you run bin/install-wp-tests.sh ? -
从阅读该教程看来,
install-wp-tests.sh是一个 UNIX shell 脚本,因此无法在 Windows 上运行 -
是的,在我发布的教程链接中没有提到,但它在 wp-cli 的实际文档中