Re: Unit Testing SCReachability framework
Re: Unit Testing SCReachability framework
- Subject: Re: Unit Testing SCReachability framework
- From: Jens Alfke <email@hidden>
- Date: Sun, 20 Jan 2013 11:45:43 -0800
On Jan 20, 2013, at 8:29 AM, Lorenzo Thurman < email@hidden> wrote: I'm using Apple's SCNetworkReachability framework to notify my app of changes in the status of the network. I install a listener function in my applicationDidFinishLaunching, which itself is a static function that posts a notification when the network status changes. I'm using OCUnit and would like to test that my listener is actually installed. How should I go about doing that? I have this called from applicationDidFinishLaunching:
I think you’d have to mock out SCNetwork somehow. For instance, you could define an Obj-C protocol wrapper around it, then implement a real version that calls SCNetwork, and a mock version that can do whatever you want under the control of your test rig. Then you configure your code to use the real one normally, but the mock one when running tests (maybe using dependency injection.)
—Jens |
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden