开发者

Is leaking objects considered OK in Testing Scenarios?

开发者 https://www.devze.com 2022-12-08 18:05 出处:网络
I have written some Objective-C test cases. A typical looks the following: - (void) test_size_Equals_Excpectation_After_initWithSize

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

精彩评论

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

关注公众号