Simple decoupled stubbing & mocking example in Swift 2

Protocols can be used to decouple our tests stubs from our code making the tests less brittle.

Create a protocol that includes only the parts you need to stub out, reducing the complexity of the interface as a result.

You have to change your production code to expect the new Protocol URLSessionDataRequestTrait. Your code now describes explicitly the requirement on NSURLSession more accurately, in my opinion. In this case only the dataTaskWithRequest() method.

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.