Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CONFIG_START - beforeAllSpecs: Never gets invoked. #652

Open
dtrenz opened this issue Oct 20, 2015 · 4 comments
Open

CONFIG_START - beforeAllSpecs: Never gets invoked. #652

dtrenz opened this issue Oct 20, 2015 · 4 comments
Assignees

Comments

@dtrenz
Copy link

dtrenz commented Oct 20, 2015

I'm not sure what I'm doing wrong.

I created a file named Config.m, added it to my unit test target, and put the following in it:

#import <Kiwi/Kiwi.h>

CONFIG_START

beforeAllSpecs(^{
  NSLog(@"BEFORE ALL SPECS");
});

CONFIG_END

But, it never gets called when I run tests. Anything obvious I may be missing?

@dtrenz
Copy link
Author

dtrenz commented Oct 22, 2015

Is this a bug, or is this feature still not really supported? I was unable to find any documentation for it.

@modocache
Copy link
Member

@dtrenz Thanks for the report! Yeah, the lack of documentation is concerning, but as far as I know it should work. I have some questions:

  1. Do you have any tests, or is your test suite comprised of just the beforeAllSpecs block?
  2. Are you running all tests (⌘+U), or are you running just one test?

Let me know if you still have access to the code that was giving you a problem, and chime in here if you're interested in helping me diagnose this further. I'll close this for now -- doing some spring cleaning on the repository. :)

@modocache
Copy link
Member

Oops, this turns out to be a regression we can confirm by running the test script. @sharplet is landing a fix now.

@sharplet
Copy link
Contributor

I've done a little bit of investigation, and here's what I've found:

  • The previous implementation was relying on the "All tests" suite being instantiated by +[XCTestSuite testSuiteWithName:]. This seems to have changed.
  • It's possible to hook -[XCTestSuite initWithName:] instead, but moving the existing implementation to that method causes Xcode itself to crash (!). Maybe dynamically changing an object's class in the middle of an initialiser is not recommended? 😛

I don't have a lot of time to investigate a workaround personally, but I'd totally accept a PR with a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants