Hi I’m developing a WordPress plugin which accesses a couple of API’s (Amazon Product API, Flickr, Freebase, Ebay).
I’ve already started writing unit tests for it but I’m still wondering if its really the way to go since it takes a lot of time downloading data from the API primarily because my download speed isn’t that fast (around 2 Mb/s max).
Currently it takes 2 hours or more to run the whole test suite and sometimes I even reach the API limit and the test won’t pass.
Is there a better way of doing this? Perhaps automating the test or even allow me to upload the tests somewhere which has a faster download speed.
Do I really need to be testing methods which access the API to begin with? Can I just make use of a mock data instead of querying the API directly?
Thanks in advance!
3
You would provide a facade for each of these APIs, which is essentially a wrapper class. So each of the API functions you are going to use will be wrapped by your own code, which you can then also mock.
This means you would have a AmazonProductAPIWrapper class which directly calls each of the APIs you are going to be consuming.