I’m new to TDD and want to set up a test environment for my wordpress plugin. I was able to find a sample plugin from wp-cli with the very useful script.

It was very easy to write the first test cases and let them execute from travis ci. The problem: I don’t want to execute the test only after a commit but continuously while development on my machine. But I’m working on a windows machine.. (mingw installed)

I’m wondering how all the plugin developer setup their test environment automated with such a script. I found open source plugins but they all use this script. It would mean all of them use linux for development or I’m doing something wrong (which seems to be more likely). But I can’t figure out how they do their test on none-unix-systems.

Any suggestions to this?

UPDATE

I have installed VVV and all is up and running. I created a sample plugin wp scaffold plugin myplugin But if I want to execute my tests I get the error that

PHP Fatal error: require_once(): Failed opening required ‘/tmp/wordpress-tests-lib/includes/functions.php’ (include_path=”/usr/local/src/composer/vendor/phpunit/php-text-template:/usr/local/src/composer/vendor/phpunit/phpunit-mock-objects:/usr/local/src/composer/vendor/phpunit/php-timer:/usr/local/src/composer/vendor/phpunit/php-token-stream:/usr/local/src/composer/vendor/phpunit/php-file-iterator:/usr/local/src/composer/vendor/phpunit/php-code-coverage:/usr/local/src/composer/vendor/phpunit/phpunit:/usr/local/src/composer/vendor/symfony/yaml:/usr/local/src/composer/vendor/phpunit/php-invoker:.:/usr/share/php:/usr/share/pear”) in /srv/www/wordpress-develop/src/wp-content/plugins/awesome-plugin/tests/bootstrap.php on line 6`

So the test environment is not installed yet. So I executed ./install-wp-tests.sh wordpress_unit_tests wp 'wp' localhost. Is this the correct way or is the use of wordpress_unit_tests dangerous? I can’t find information how to install the wordpress test environment the right way anywhere?!

1
1

Your best bet to set up a reusable test environment on a Windows machine is to use Vagrant with a setup such as this. Vagrant will allow you to build portable, reusable virtual machines with a very simple interface which you can use across different operating systems and team members.

To set it up, you have to download Vagrant for Windows from here. Then you have to download the VVV setup(linked above), extract it, and follow the instructions on their github page.

Leave a Reply

Your email address will not be published. Required fields are marked *