【发布时间】:2013-03-26 17:19:41
【问题描述】:
我在 Objective-C 方面没有太多经验,但我想开始使用 TDD 在 iOS 中进行开发,对此我有几个新手问题 :)
人们在 iOS 的 TDD 中使用什么?我想在使用 Xcode 中已有的测试框架时,它好吗?还是有更好的选择?
我正在尝试为单元测试做一些练习,我正在创建一个示例,其中我有一个 TableViewControllerClass,使用 CoreLocation,使用以下方法:
-(void)startFindLocation
{
[self.cllManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations
{
[self.cllManager stopUpdatingLocation];
CLLocation *actualLocation = [locations lastObject];
NSLog(@"latitude: %f", actualLocation.coordinate.latitude);
NSLog(@"longitude: %f", actualLocation.coordinate.longitude);
}
我想测试的,很简单,就是看CLLocation有没有经纬度,而不是用NSLong。 为此,我真的需要在我的测试类中分配和初始化这个 TableViewController 类吗?或者有任何框架,类似于 Rspec(例如,ruby/rails),我可以在其中检查应用程序屏幕中的特定标签是否具有此纬度和经度值?
问候
【问题讨论】:
标签: ios objective-c xcode unit-testing tdd