7

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
  • install-wp-tests.sh for PHPUnit is already done on this Vagrant environment. Please try! vccw.cc
    – user54471
    Commented Jun 20, 2014 at 2:55

1 Answer 1

2

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.

5
  • Wow. Thank you! It was really easy to install VVV and let the unit tests run. I'm on OSX and running Windows in a VM (via Parallels) because the development tools are better imho. The Problem is: 1. I can't run Parallels and Virtual Box at the same time.. 2. I can't run virtual box in the windows vm. So all is up and running but I can't develop at least.
    – No3x
    Commented May 24, 2014 at 20:44
  • @No3x What are the development tools that you need Windows for? Maybe you can find alternatives. Commented May 29, 2014 at 7:12
  • @No3x If this has solved your problem, please mark my answer as the correct one. Commented Jun 1, 2015 at 14:32
  • Gaurav Pareek After some problems with virtual box I was able to use VVV. But it's kinda slow. Without the need to run windows in a VM this would be the way to go. Another path I tried was to use my root server and sync all changes with an IDE. Both ways are OK but not convenient. I will upvote your answer, but this case is not resolved.
    – No3x
    Commented Jun 1, 2015 at 19:42
  • 1
    @No3x In that case, can you update the question to reflect that you want to run the Windows environment in a Virtual Machine. Also, can't you just run vagrant on your main host and set up networking such as to access it through your Windows VM? Commented Jun 2, 2015 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.