I'm using XCTest to write unit tests in my project, and when using the XCAssertNil()
or XCAssertNotNil()
methods, XCTest framework crashes.
Here's my test:
XCTAssertNotNil(messageCollection.fieldName, "field_name must be not-nil")
Here's the stack trace:
2015-06-22 17:05:17.629 xctest[745:8747] *** Assertion failure in void _XCTFailureHandler(XCTestCase *, BOOL, const char *, NSUInteger, NSString *, NSString *, ...)(), /SourceCache/XCTest_Sim/XCTest-7701/XCTestFramework/OtherSources/XCTestAssertionsImpl.m:41
Test Case '-[Wakanda_iOS_Framework_Tests.WAKAdapterTest testEntityCollectionParsing]' started.
2015-06-22 17:05:17.631 xctest[745:8747] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Parameter "test" must not be nil.'
It seems that XCTest has a parameter named test which cannot be nil, strange for a method expected to check for nil (or non-nil) values... Does anyone else got this problem and solved it?
Since your "test" is nil, I'm guessing you're trying to call
XCAssertNil
from a standalone function you wrote as a helper. The XCTest assertions takeself
as "test", so they can't be in standalone functions. They must be in methods. Try changing your helper function to a method.