Reputation: 569
I posted question here about sending request via SMS API.
But I want to unit test here using JUnit? How do I go about this effectively? I am very new to JUnit and completely clueless.
Any help in getting me started will be thoroughly appreciated
Upvotes: 1
Views: 2842
Reputation: 7275
Some examples of mocking HttpURLConnection with Mockito:
https://gist.github.com/leviwilson/3623053 Issues with Mocking HttpURLConnection using Mockito
Remember that for unit testing, you want to mock anything that goes over the network, makes a database call, etc.
If you had no internet access at all, the tests should still work.
Also don't worry about unit testing third-party libraries. If you want to test a message actually going out over HTTP, then you want to do integration testing.
Upvotes: 1