kiwi-bdd / Kiwi

Simple BDD for iOS
BSD 3-Clause "New" or "Revised" License
4.14k stars 512 forks source link

Using a sharedExample in another #694

Open marcuswu0814 opened 7 years ago

marcuswu0814 commented 7 years ago

Hi, @ecaselles Thanks for the implement of sharedExample, this is useful for me.

But when I used it, I face some question, Is possible used a sharedExample in another sharedExample?

ecaselles commented 7 years ago

Hi @marcuswu0814,

TBH, I don't think I have ever tried 🤷🏻‍♂️ I can't think of a reason (without checking the implementation again) on why not. But I will try to write a test for it and let you know. If you have already tried and have an example or sample project, it would be great if you share your findings 😉

marcuswu0814 commented 7 years ago

Hi @ecaselles

It will crash before running test at run time. Just using itBehavesLike() in another shareExample can reproduce this problem.

Crash log

2017-06-13 18:41:59.793 MYPROJECT_[88198:6249852] Debug details follow:
*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]
(
    "4   libc++abi.dylib                     0x0000000119ef726e _ZSt11__terminatePFvvE + 8",
    "5   libc++abi.dylib                     0x0000000119ef6ef9 __cxa_rethrow + 99",
    "6   libobjc.A.dylib                     0x0000000119434f5e objc_exception_rethrow + 40",
    "7   CoreFoundation                      0x000000010f0601b4 CFRunLoopRunSpecific + 676",
    "8   GraphicsServices                    0x000000011c398ad2 GSEventRunModal + 161"
)
2017-06-13 18:41:59.793 MYPROJECT_[88198:6249852] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010f145d85 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000119434deb objc_exception_throw + 48
    2   CoreFoundation                      0x000000010f04223e -[__NSPlaceholderDictionary initWithObjects:forKeys:count:] + 318
    3   CoreFoundation                      0x000000010f0545bb +[NSDictionary dictionaryWithObjects:forKeys:count:] + 59
    4   MYPROJECT_UnitTest                     0x0000000127e79871 __59+[KWSharedExample(MyTestSpecHelpers) load]_block_invoke.34 + 305
    5   Kiwi                                0x0000000128a3ff6a __itBehavesLike_block_invoke + 74
    6   Kiwi                                0x0000000128a221c4 contextWithCallSite + 180
    7   Kiwi                                0x0000000128a220cd context + 109
    8   Kiwi                                0x0000000128a3fea8 itBehavesLike + 376
    9   MYPROJECT_UnitTest                     0x0000000127e82fd8 __49+[MyTestSpec buildExampleGroups]_block_invoke_6 + 456
    10  Kiwi                                0x0000000128a221c4 contextWithCallSite + 180
    11  Kiwi                                0x0000000128a220cd context + 109
    12  MYPROJECT_UnitTest                     0x0000000127e8184d __49+[MyTestSpec buildExampleGroups]_block_invoke.415 + 141
    13  Kiwi                                0x0000000128a221c4 contextWithCallSite + 180
    14  Kiwi                                0x0000000128a22026 describeWithCallSite + 118
    15  Kiwi                                0x0000000128a21f6d describe + 109
    16  MYPROJECT_UnitTest                     0x0000000127e815b6 __49+[MyTestSpec buildExampleGroups]_block_invoke + 342
    17  Kiwi                                0x0000000128a221c4 contextWithCallSite + 180
    18  Kiwi                                0x0000000128a22026 describeWithCallSite + 118
    19  Kiwi                                0x0000000128a21f6d describe + 109
    20  MYPROJECT_UnitTest                     0x0000000127e8144d +[MyTestSpec buildExampleGroups] + 93
    21  Kiwi                                0x0000000128a40c43 __25+[KWSpec testInvocations]_block_invoke + 35
    22  Kiwi                                0x0000000128a23c0f -[KWExampleSuiteBuilder buildExampleSuite:] + 367
    23  Kiwi                                0x0000000128a40966 +[KWSpec testInvocations] + 326
    24  XCTest                              0x0000000126d3b3bd +[XCTestSuite testSuiteForTestCaseClass:] + 115
    25  XCTest                              0x0000000126d3aff9 +[XCTestSuite _suiteForBundleCache] + 517
    26  XCTest                              0x0000000126d3c8bd -[XCTestSuite _initWithTestConfiguration:] + 1546
    27  XCTest                              0x0000000126d3cd67 +[XCTestSuite testSuiteForTestConfiguration:] + 50
    28  XCTest                              0x0000000126d888b3 -[XCTTestRunSession runTestsAndReturnError:] + 167
    29  XCTest                              0x0000000126d26a50 -[XCTestDriver runTestsAndReturnError:] + 254
    30  XCTest                              0x0000000126d8086e _XCTestMain + 559
    31  CoreFoundation                      0x000000010f06b2ec __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    32  CoreFoundation                      0x000000010f060f75 __CFRunLoopDoBlocks + 341
    33  CoreFoundation                      0x000000010f0606d2 __CFRunLoopRun + 850
    34  CoreFoundation                      0x000000010f0600f8 CFRunLoopRunSpecific + 488
    35  GraphicsServices                    0x000000011c398ad2 GSEventRunModal + 161
    36  UIKit                               0x0000000111078f09 UIApplicationMain + 171
    37  MYPROJECT_                             0x000000010cc1139f main + 111
    38  libdyld.dylib                       0x000000011a02592d start + 1
    39  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Signal: SIGABRT (signal SIGABRT)