开发者

Is leaking objects considered OK in Testing Scenarios?

I have written some Objective-C test cases. A typical looks the following:

- (void) test_size_Equals_Excpectation_After_initWithSize
{
    int size = 10;
    Buffer* buff = [[Buffer alloc] initWithSize:size];

    GHAssertEquals([buff size], size, nil);
}

Buffer alloc returns buffer with reference count 1, I didn't care to call autorelease on buffer, so it is leaked after the funciton exits. Is this acceptable i开发者_StackOverflown testing scenarios?


Doesn't sound like a good idea.

Your test code should be written as well as app code.

It's all code.

Who's to say that leak doesn't have adverse effects on the rest of your tests causing some failures to be reported as successes or vice versa?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜