Disable assertions during testing

I want to check my API contract so that if for example an object is created with some parameter before the nil

assertion is raised, but if the assertions are disabled (Release config) it just returns nil.

My test schema has a build config for Debug, so in my tests on the API contract, I check if creating an object with some parameters returns nil, returns a nil object. But the constructor assertion occurs before execution XCTAssertNil

, so my test always fails.

Can assertions be turned off during testing? I tried adding NS_BLOCK_ASSERTIONS

to the schema arguments passed on startup, but that doesn't work.

+3


source to share


1 answer


Solved, I added a new config duplicated from Debug called Test

.

enter image description here

Then added NS_BLOCK_ASSERTIONS=1

in the build settings preprocessor macros.

enter image description here



Finally, change the test action in the test schema.

enter image description here

It works now :)

+4


source







All Articles