lundi 1 février 2016

Is it possible to stub NSProcessInfo with OCMock?

I want to stub [[NSProcessInfo processInfo] operatingSystemVersion] to take any OS version.

id processInfoMock = OCMClassMock([NSProcessInfo class]);
[OCMStub([processInfoMock operatingSystemVersion]) andReturnValue:NULL];
NSOperatingSystemVersion osVersion = [[NSProcessInfo processInfo] operatingSystemVersion];

But iOS simulator's OS version is returned. Is it possible to stub NSProcessInfo methods? And, Is it appropriate to stub Foundation's classes?

Aucun commentaire:

Enregistrer un commentaire