I known we can get the sampleData as response, but I don't know how to write test for request? If there have any examples about how to make unit test? Thanks
Hey @longshihua, this is a good one. Testing is our top priority, so we should've better documentation around that. We are working on it, but in the meantime...
If we are talking about testing with sampleData in unit tests, you can see it in our tests how we do it here. Basically we use stubbingClosure and check the data from the response. If we are talking about testing without using any stubbing option built in in Moya, we have these as well. For that purpose we use OHHTTPStubs, you can see how we do it here.
Hope it helps!
This issue has been marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
This issue has been auto-closed because there hasn't been any activity for 59 days. However, we really appreciate your contribution, so thank you for that! 馃檹 Also, feel free to open a new issue if you still experience this problem 馃憤.
As @sunshinejr mention, you can test the .sampleData like they do on the link that he provided. However if what you are looking is to test your RequestManager, NetworkManager or whatever you are using to encapsulate your request you can check this.
Most helpful comment
Hey @longshihua, this is a good one. Testing is our top priority, so we should've better documentation around that. We are working on it, but in the meantime...
If we are talking about testing with
sampleDatain unit tests, you can see it in our tests how we do it here. Basically we usestubbingClosureand check the data from the response. If we are talking about testing without using any stubbing option built in in Moya, we have these as well. For that purpose we use OHHTTPStubs, you can see how we do it here.Hope it helps!