Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
NetworkReachabilityManager subclassing issue #1809
We're trying to write unit tests around our usage of NetworkReachabilityManager by subclassing it to mock out some behavior for the purposes of tests. We seem to have identified an issue because the class is marked as open but because of the design of the initializers there doesn't seem to be a way to subclass it in a way that compiles. Currently there are 3 inits for NetworkReachabilityManager:
This is a problem because if we create a subclass there is no way to properly init it as we cannot call the base class designated initializer which is required by the compiler.
Either the initializers need to be adjusted to allow for this or perhaps the class should not be marked as open.
To clarify, it wasn't to test the ReachabilityManager, it was a way to mock out its behavior to test OUR code that utilizes the ReachabilityManager
The goal was to make it mockable so you could define a protocol for this which we could mock or adjust the initializers for subclassing. Either would meet the need.
added a commit
Dec 19, 2016
Thanks for letting us know @SlashDevSlashGnoll. You are absolutely right, it was not set up correctly at all. Upon further investigation, we realized we never should have made the class
If you need to "proxy" the functionality for testing, you'll want to create a proxy protocol and have the
This change will go out as part of the 4.3.0 release here shortly.