开发者

Should I test a model class which sync often to the server?

And how do I do it, since obviously there are a lot of async methods, and no way (that I know of) to check them in a unit test.

For example:


- (void) testSomeTest {
// things
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(helperTestSome开发者_Go百科Test:)
name:connectionFinished
object:nil];
// connect to server
}
- (void) helperTestSomeTest:(NSNotification)notification {
 STAssertWhatever(whathever, nil); // not working
}


You have a variety of solutions to Unit test this. Mock objects, Stubs, and Fakes all come to mind.

They seem similar, but this is a great look at the differences.

By the way, to directly answer your question-line: Yes, test 100% of the code. Everything.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜