How do you test a Presenter without UIKit?
The point
A Presenter in MVP talks to the View through a protocol and to services through injected protocols. So in a test:
- instead of the View we inject a spy — a class that implements the protocol and records calls;
- instead of the service — a stub that returns a canned result;
- we call the Presenter's method and check what it told the View and with which data.
UIKit is not imported, no controller is created, no simulator is needed — the test runs in milliseconds and can run on a macOS host.
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep