In an XCTestCase function, can I immediately pass the test without actually returning from the function?

23 Views Asked by At

The title sounds very hacky, to be sure, but hear me out. I work on a framework, and one of our constant headaches is dealing with over-released pointers. I'm writing some test cases in which I manually release an object to the point where it gets deallocated, alongside some tests to make sure our code handles that properly. It's not a very realistic scenario, I know, but still.

The problem is - because the object has been deallocated and the pointer is bad, when the test function exits, it attempts to release the object again, which crashes of course. I've thought about putting these tests in a file that has ARC disabled, but would rather not. So my question is this:

Is there a way to immediately exit a test case function such that the test passes, but does not attempt to release any of the variables used in it? Or any ideas on perhaps re-allocating the object so it can be released properly?

0

There are 0 best solutions below