I’d like to execute more than one statement in the STAssertXX family of macros, is that possible? Something like:
STAssertTrue([foo doSomething] && [barDoSomethingElse], @"Should…");
The code above works for methods that return booleans, I’d like something similar for void return types:
STAssertNoThrow({
[foo doSomething];
[bar doSomethingElse];
}, @"Should…");
Of course, here the preprocessor complains.
Since any valid C code is also valid Objective-C; you can use the
,operator from C for a single argument, as long as you use it in parenthesis.Like this:
The
,operator lets you composite several expressions as a single statement returning the value of the last expression.I would advise strongly against using this in
STAssert…statements since you will loose important information about which tests that failed.