dimanche 29 novembre 2015

TDD: How to write unit tests when method depends on network URL's

I try to write method which consumes some url address, and returns resources (RSS feeds for instance).

public class NewsSourcesService {

    public List<News> getNewsSource(String url) {

    }

}

I plan to use ROME internally, but it shouldn't be visible by dependencies. It's difficult to write unit test for that method, because preparing fake state is impossible and there is nothing to mock.

What is the best approach for writing tests in such cases?

Aucun commentaire:

Enregistrer un commentaire