• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
XCTest KVO exception: "Cannot remove an observer <_XCKVOExpectation ..."
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

XCTest KVO exception: "Cannot remove an observer <_XCKVOExpectation ..."


  • Subject: XCTest KVO exception: "Cannot remove an observer <_XCKVOExpectation ..."
  • From: Jens Alfke <email@hidden>
  • Date: Mon, 17 Aug 2015 13:53:45 -0700

I’ve been using the very handy “expectation” API in XCTestCase, for testing asynchronous operations. But one particular test is occasionally failing in our Xcode bot, never for me, with a weird exception. It looks like the implementation of -keyValueObservingExpectationForObject:… isn’t handling KVO registration properly:

Assertion: failed: caught "NSRangeException", "Cannot remove an observer <_XCKVOExpectation 0x1056a00c0> for the key path "fractionCompleted" from <NSProgress 0x10a01ae90> because it is not registered as an observer."
(
	0   CoreFoundation                      0x00007fff8ab8403c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x00007fff9249c76e objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8ab83eed +[NSException raise:format:] + 205
	3   Foundation                          0x00007fff90f5a896 -[NSObject(NSKeyValueObserverRegistration) _removeObserver:forProperty:] + 604
	4   Foundation                          0x00007fff90f5a5d9 -[NSObject(NSKeyValueObserverRegistration) removeObserver:forKeyPath:] + 114
	5   XCTest                              0x0000000100099d57 -[_XCKVOExpectation _safelyUnregister] + 96
	6   XCTest                              0x000000010008eae2 -[_XCTestCaseImplementation resetExpectations] + 231
	7   CBL Mac Unit Tests                  0x0000000104bf2f5c -[Replication_Tests test20_LazyPullAttachments] + 10268
	8   CoreFoundation                      0x00007fff8aa5b7bc __invoking___ + 140
	9   CoreFoundation                      0x00007fff8aa5b612 -[NSInvocation invoke] + 290
	10  XCTest                              0x000000010008b9fc -[XCTestCase invokeTest] + 253
	11  CBL Mac Unit Tests                  0x0000000104a78b37 -[CBLTestCaseWithDB invokeTest] + 119
	12  CBL Mac Unit Tests                  0x0000000104ba7275 -[Replication_Tests invokeTest] + 69
	13  XCTest                              0x000000010008bbfb -[XCTestCase performTest:] + 150
	…

I’m not sure what to do about this since I own neither the code that does the observing nor the class being observed. I’ll probably file a bug against Xcode, but I’m wondering if anyone else has run into this exception?

—Jens
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: XCTest KVO exception: "Cannot remove an observer <_XCKVOExpectation ..."
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Xcode won't let me see the build log
  • Next by Date: Re: XCTest KVO exception: "Cannot remove an observer <_XCKVOExpectation ..."
  • Previous by thread: Xcode won't let me see the build log
  • Next by thread: Re: XCTest KVO exception: "Cannot remove an observer <_XCKVOExpectation ..."
  • Index(es):
    • Date
    • Thread