Install and load additional plugins when running unit tests

What you are trying to do is not unit testing but integration testing, and as integration usually requires some initialization which will be specific to the relevant plugin it is hard to give a general answer which is more then the obvious”include the plugin file”

The idea of unit testing is to check that your APIs do what they are supposed to do and the base assumption should be that external APIs work correctly, otherwise there is just no limit to the amount of tests you will have to write.

Once you assume that the external APIs work correctly it doesn’t make any difference if you actually call them or just write a function in the same name that just mimics their behavior.

As an example to the idea. In a plugin I write there are several settings that control with which argument WP_Query is being called. To test that I just check the resulting array of argument without bothering actually calling WP_Query.

Leave a Comment