jeudi 8 septembre 2016

python/django unittest, how to handle outside calls?

I read multiple times that one should use mock to mimic outside calls and there should be no calls made to any outside serviec because your tests need to run regardless of outside services.

This totally makes sense....BUT

What about outside services changing? What good is a test, testing that my code works like it should if I will never know when it breaks because of the outside service being modified/updated/removed/deprecated/etc...

How can I reconcile this? pseudo code below

function post_tweet:
    data = {"tweet":"tweetcontent"}
    send request to twitter
    receive response 
    return response

If I mock this there is no way I will be notified that twitter changed their API and now I have to update my test...

Aucun commentaire:

Enregistrer un commentaire