尝试使用Quick测试Swift - PFObject时出错

时间:2015-08-05 04:05:04

标签: ios swift parse-platform pfobject

我需要为Swift-PFObject(使用Subclassing)编写一些快速测试,我的课程:

class Category: PFObject, PFSubclassing {

  @NSManaged var name : String!
  @NSManaged var detail : String!
  @NSManaged var iconUrl : String!
  @NSManaged var imageUrl: String!
  @NSManaged var people : PFRelation!

  override class func initialize() {
    var onceToken : dispatch_once_t = 0;
    dispatch_once(&onceToken) {
      self.registerSubclass()
    }
  }

  class func parseClassName() -> String {
    return "Category"
  }

}

我的测试实施(尚未完成):

class CategorySpec: QuickSpec {

  override func spec() {
    var category = Category()
    .
    .
    .

  }

}

我已经检查了目标会员资格'对于类别类中的测试:(在我的类和方法中不使用公共关键字)。

这是运行测试时的堆栈跟踪:

2015-08-04 23:52:07.314 SnipMe[14216:127914] *** Terminating app due to uncaught exception     'NSInternalInconsistencyException', reason: 'Tried to register both SnipMe.Category and SnipMeTests.Category     as the native PFObject subclass of Category. Cannot determine the right class to use because neither     inherits from the other.'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010fa64c65 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010feffbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010fa64b9d +[NSException raise:format:] + 205
    3   Parse                               0x000000010e0d9a67 +[PFObject registerSubclass] + 536
    4   SnipMeTests                         0x000000011c6b77ef     _TFZFC11SnipMeTests8Category10initializeFMS0_FT_T_U_FT_T_ + 63
    5   SnipMeTests                         0x000000011c6b7187 _TTRXFo__dT__XFdCb__dT__ + 39
    6   libdispatch.dylib                   0x0000000111360964 _dispatch_client_callout + 8
    7   libdispatch.dylib                   0x000000011134e902 dispatch_once_f + 129
    8   SnipMeTests                         0x000000011c6b727a     _TZFC11SnipMeTests8Category10initializefMS0_FT_T_ + 234
    9   SnipMeTests                         0x000000011c6b7359     _TToZFC11SnipMeTests8Category10initializefMS0_FT_T_ + 25
    10  libobjc.A.dylib                     0x000000010ff004d6 _class_initialize + 648
    11  libobjc.A.dylib                     0x000000010ff096e1 lookUpImpOrForward + 351
    12  libobjc.A.dylib                     0x000000010ff160d3 objc_msgSend + 211
    13  SnipMeTests                         0x000000011c6b7437 _TMaC11SnipMeTests8Category + 39
    14  SnipMeTests                         0x000000011c6b4d88 _TFC11SnipMeTests12CategorySpec4specfS0_FT_T_ +     24
    15  SnipMeTests                         0x000000011c6b4eb2 _TToFC11SnipMeTests12CategorySpec4specfS0_FT_T_     + 34
    16  Quick                               0x000000011c7e673a +[QuickSpec initialize] + 202
    17  libobjc.A.dylib                     0x000000010ff004d6 _class_initialize + 648
    18  libobjc.A.dylib                     0x000000010ff096e1 lookUpImpOrForward + 351
    19  libobjc.A.dylib                     0x000000010ff160d3 objc_msgSend + 211
    20  CoreFoundation                      0x000000010f9999ad -[__NSSetM member:] + 77
    21  CoreFoundation                      0x000000010f987da6 -[NSSet containsObject:] + 22
    22  XCTest                              0x000000011c6d975a +[XCTestCase(RuntimeUtilities) allSubclasses] +     159
    23  XCTest                              0x000000011c6cc59c +[XCTestSuite _suiteForBundleCache] + 183
    24  XCTest                              0x000000011c6cc777 +[XCTestSuite suiteForBundleCache] + 34
    25  XCTest                              0x000000011c6ccb0a +[XCTestSuite allTests] + 56
    26  XCTest                              0x000000011c6da83a __33+[XCTestProbe     specifiedTestSuite]_block_invoke + 87
    27  libdispatch.dylib                   0x0000000111360964 _dispatch_client_callout + 8
    28  libdispatch.dylib                   0x000000011134e902 dispatch_once_f + 129
    29  XCTest                              0x000000011c6da7e1 +[XCTestProbe specifiedTestSuite] + 98
    30  XCTest                              0x000000011c6daada +[XCTestProbe runTests:] + 112
    31  Foundation                          0x000000010d9d61e5 __NSFireDelayedPerform + 387
    32  CoreFoundation                      0x000000010f9cc174     __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    33  CoreFoundation                      0x000000010f9cbd35 __CFRunLoopDoTimer + 1045
    34  CoreFoundation                      0x000000010f98dd3d __CFRunLoopRun + 1901
    35  CoreFoundation                      0x000000010f98d366 CFRunLoopRunSpecific + 470
    36  GraphicsServices                    0x0000000113027a3e GSEventRunModal + 161
    37  UIKit                               0x000000010e4b98c0 UIApplicationMain + 1282
    38  SnipMe                              0x000000010d4e7f67 main + 135
    39  libdyld.dylib                       0x0000000111391145 start + 1
    40  ???                                 0x000000000000000a 0x0 + 10
)
libc++abi.dylib: terminating with uncaught exception of type NSException    

有什么想法吗?提前谢谢。

0 个答案:

没有答案