简体   繁体   中英

OCMock/OCMVerify - Expression result unused

Calls like the following don't compile because of Expression result unused warning/error:

id object = [Foo new];
id mockObject = OCMPartialMock(object);
...
OCMExpect([mockObject doTheThing]);
...
OCMVerify(mockObject);

Tested on Xcode 12 GM:

$ clang -v
Apple clang version 12.0.0 (clang-1200.0.32.2)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Applications/Xcode_12_GM.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

Replace OCMVerify(...) with OCMVerifyAll(...) .

OCMVerify(...) is to verify after calls after running while OCMVerifyAll(...) is to verify expectations declared before running.

id object = [Foo new];
id mockObject = OCMPartialMock(object);
...
OCMExpect([mockObject doTheThing]);
...
OCMVerifyAll(mockObject);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM