nmdias / FeedKit

An RSS, Atom and JSON Feed parser written in Swift
MIT License
1.19k stars 174 forks source link

Since RSSFeedItem has a closed initializer, how can I mock some results when testing? #81

Closed ksoftllc closed 5 years ago

ksoftllc commented 5 years ago

I'd like to be able to mock my RSS feed for unit testing. How can I provide a mock array of RSSFeedItem instances?

nmdias commented 5 years ago

Hi, @ksoftllc

You can't, at the time. Look for FeedKit's existing unit tests. That's all we have. I'll make sure to open the initializers to outside the framework in the near future. For now it will have to wait.

Thanks

ksoftllc commented 5 years ago

Hoping you decide to permit some sort of mocking in the future. I'd like to be able to unit test my code with predictable contents. That rules out using real RSS feeds. I'm going to try using httpbin.org for my testing. Thanks for the quick response.

nmdias commented 5 years ago

I will. In the meantime, if you're considering httpbin.org, maybe have a look at the BaseTestCase class. You could just provide the file locally, if that helps.

nmdias commented 5 years ago

Hi, @ksoftllc.

The commit above should have fixed it. I'll still have to release a new version, but in the meantime, if you point your dependencies manager to the master branch, it should work fine.

I'll close this for now. Mock away 😃

Thanks