Our company is using an external API that is actually in beta state.This means it's not stable at all yet, and it changes its requests/responses every week or so. I'd like to write test to ensure my code is working. Unit tests are already done for my own code.But the API itself isn't tested, because it would violate the first rule of FIRST (Fast tests). If I test the API requests/responses 'live' (they have a sandbox version of the API), tests take around 7 seconds for themselves. That's a long time.How could I be sure the API still uses the same structure for requests and responses in this case, is it a special case where slow tests are ok ? My hierarchy wants to use this API asap obviously, and I don't want any bug whatsoever.
Testing an external API that's in beta state
php;api;phpunit
I'd like to write test to ensure my code is working. Unit tests are  already done for my own code. But the API itself isn't tested, because  it would violate the first rule of FIRST (Fast tests). If I test the  API requests/responses 'live' (they have a sandbox version of the  API), tests take around 7 seconds for themselves. That's a long time.I completely agree that adding 7 seconds to your unit tests is not ideal - but even if it was 7 microseconds you still shouldn't test the API with unit tests in your code. You don't need to test the API every time you make a change to your code - and you do need to test it even if you don't make changes to your code for a month: you need to test it every time they make changes to their code.Of course, you don't know how often they do that, so I'd suggest running the test automatically once an hour/day/week, depending on how often you expect changes.Of course, whether it's a good idea to actually have those tests is debatable. Personally, I believe that having some sanity checks makes sense, especially for unstable services where someone may make a change without even changing the patch version and then you have to investigate for hours till you realise it - but I digress: even assuming best practices, you might have misinterpreted the API and a change that wouldn't have affected normal use of it breaks your code.