This is an example of how I would use XCTAssertEqual
XCTAssertEqual(valueA, valueB, @"message");
However, when I try the following
NSString *message = @"message";
XCTAssertEqual(valueA, valueB, message);
I get a compiler error, namely,
Expected ')'
It seems like I am simply passing an NSString either way. When i dig into the definition I find
#define XCTAssertEqual(a1, a2, format...) _XCTPrimitiveAssertEqual(a1, a2, ## format)
Which I cannot make heads or tails of. Why am I unable to pass an NSString*
as the format...
argument into XCTAssertEquals, when it accepts NSString literals like @"message"
?
Note: This appears to be the case for all the assertions.
Try this:
XCTAssertEqual(valueA, valueB, @"%@", message);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With