我正在尝试使用Kiwi框架测试ReactiveCocoa代码。
这是代码:
-(void)bindParentModel:(FEPVehiclePropertyModel*)theParentModel{
self.parentModel = theParentModel;
[RACObserve(self, parentModel.currentName) subscribeNext:^(NSString* modelName) {
self.avaliableVales = [FEPVehiclePropertyValuesContainer possibleVlauesForKey:modelName];
if (![self.avaliableVales containsObject:self.currentName]){
self.currentName = [self.avaliableVales firstObject];
}
}];
}
这是测试用例
it(@"check vehicle model binding", ^{
NSArray* carModel = [FEPVehiclePropertyValuesContainer possibleVlauesForKey:@"2013"];
FEPVehiclePropertyModel* model = [[FEPVehiclePropertyModel alloc] init];
FEPVehiclePropertyModel* parenModel = [[FEPVehiclePropertyModel alloc] init];
parenModel.parentModel = nil;
parenModel.avaliableVales = carModel;
parenModel.currentName = [carModel lastObject];
[model bindParentModel:parenModel];
parenModel.currentName = [parenModel.avaliableVales firstObject];
[[model.currentName should] equal:@"2.0L GTDI EcoBoost 6-speed manual"];
});
每次运行测试用例时,我在RACKVOTrampoline类中尝试了EXC_BAD_ACCESS 添加观察者
[self.target addObserver:self forKeyPath:self.keyPath options:options context:&RACKVOWrapperContext];
有什么建议吗?
生产代码可以很好地使用ReactiveCocoa。