These are chat archives for padrino/padrino-framework

Jun 2017
Sushant Bajracharya
Jun 30 2017 03:52

spent couple of days learning testing. I was wondering how i will be able to unit test this piece of code

While writin unit test, it should not have other api , db call dependencies right? so how should i test it?

Sushant Bajracharya
Jun 30 2017 03:59
my app , fuitter , deals with facebook`s graph api. is unit test even possible in this scenarios?
Jun 30 2017 15:47
adam12 @sushant12 You can't unit test the Facebook API, but you could "stub" a small portion of the app, where you call Facebook, and have it return whatever you want, instead of calling facebook directly.
adam12 @sushant12 You should work on using classes more - in this case, you should have a class that wraps the Facebook API. When you do that, you can "monkeypatch" the class methods during testing to bypass the actual facebook calls.
adam12 @sushant12 ALso, find_large_image_url makes me assume that it would RETURN a URL, but your code actually fetches and saves photos. I think it should be named something else entirely.
adam12 @sushant12 Maybe you could have a class called FacebookAlbum, which receives obj (whatever obj is??), and then does the lookup to the facebook api
adam12 @sushant12 You should then call another class to follow Single Responsibility Principle