Is there some reason my Kiwi unit tests are failing with these two lines:

[[theValue([editAuthorViewController class] == [EditAuthorViewController class]) should] beYes];

[[theValue([editAuthorViewController isKindOfClass:[EditAuthorViewController class]]) should] beYes];

While this line passes?

NSString *classString = NSStringFromClass([editAuthorViewController class]);
[[classString should] equal:@"EditAuthorViewController"];
有帮助吗?

解决方案

Turns out there's a Kiwi expression to test this I wasn't aware of.

[[editAuthorViewController should] beKindOfClass:[EditAuthorViewController class]];

This failed initially because my EditAuthorViewController.m file was added to my test target. Since [EditAuthorViewController class] was returning a different pointer when called from inside the test bundle, the comparison failed.

To fix this, I had to remove EditAuthorViewController.m from my Compile Sources in my test target.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top