0

I want to test webservice response using xctest in objective C.

I am having some issues while using

- (XCTestExpectation *)keyValueObservingExpectationForObject:(id)objectToObserve keyPath:(NSString *)keyPath expectedValue:(nullable id)expectedValue;

or

- (XCTestExpectation *)keyValueObservingExpectationForObject:(id)objectToObserve keyPath:(NSString *)keyPath handler:(nullable XCKeyValueObservingExpectationHandler)handler;

Does any one know some tutorial link or example so that I can understand correct use of it?

Thanks

Losiowaty
  • 7,911
  • 2
  • 32
  • 47
user1101733
  • 258
  • 2
  • 14
  • What exactly is your test case? Can you show the method/class you want to test? How does KVO fit into it all? This article : http://nshipster.com/xctestcase/ has a chapter on `XCTestExpectation` and how to use it for asynchronous connections. – Losiowaty Sep 14 '16 at 14:32
  • I have declare one property in my class which is readwrite and its value gets change in success or failure block when a webservice call completed. – user1101733 Sep 14 '16 at 15:04
  • I have declared the same property as readonly in class extension and using that extension in testcase class to access the private propery. To call a method which initiate webservice I have to push that controller and for this I have set an expectation. Once that controller is pushed I have to set another expectation to observe the controller's property value. What is the best approach to do it? – user1101733 Sep 14 '16 at 15:16
  • You shouldn't need to rely on the pushing part. In general a unit test should test one thing only. Can you edit your question and post the controllers code and tell us which method you want to test? – Losiowaty Sep 14 '16 at 15:22

0 Answers0