I am trying to integrate my app to work with Vimeo api ( video uploading - getting a video - deleting a video .. etc)
this is my first time trying to test an external API ..
How should I start testing the API ? what are your experiences in this ?
For example: should I test the deleting directly like this ?
protected function setUp() : void
{
parent::setUp();
$this->vimeo = new VimeoApiClient();
}
/** @test */
public function a_video_can_be_deleted()
{
$video = $this->vimeo->upload($video);
// make http request to delete the video
$result = $this->vimeo->delete($video['id']);
$this->assertEquals('success', $result['status']);
}
I would be reluctant to be testing against a live API directly, from the point of view or (i) test execution speed, (ii) possible API rate limits, (iii) not putting testing artefacts on the API that are not subsequently cleaned up,.
What is VimeoApiClient; your own code or third-party? If it is a reliable third-party package, then it is most likely already tested. If not, then find a third party package that is tested. In any case, test your integration with that package, rather than testing what the package does.
Yes, VimeoApiClient is a reliable package with tests.
but, isn't more reliable to test this integration using a real requests to Vimeo servers than mocking that package?
I think execution speed is not a problem, since I can exclude these kind of tests whenever I want to using "groups". Is it really a bad idea to test integration this way?
I have the same issue, but in my case the service I'm using is de-standardized and also I'm using a library that was also done by my but the playground key doesn't permit all operations so yes Im testing the integration too.
But I mark it as a $this->markTestAsRisky() or $this->markTestAsSkiped() and it will skip that test and once in a while I reactivate them just to try it.
If the api you are using looks robuts you could mock it