Skip to content

Conversation

@paweldudek
Copy link
Contributor

This PR is an attempt to fix #270.

It looks like that early test observer registration (aka as early as you can - in +load) prevents default XCTest observer from registering in latest XCTest that shipped with Xcode 7.

That default observer is responsible for printing output to Xcode console (or Terminal when running xcodebuild from command line). There are several tools that rely on this output, for instance xcpretty.

This simple PR adds logic that defers the moment where CurrentTestCaseTracker and thus allows default XCTest observer to register.

Potential issues: There should not be any issues with CurrentTestCaseTracker being registered too late as we're moving the registration to next run loop cycle (which is the moment after all classes and categories get their +load message). However I'm entirely certain about and any input on whether this is a viable solution is welcomed.

Or perhaps better alternatives, as I'm not a huge fan of using dispatch_async this way 😉

I've tested this against my test suite and it works just fine.

@ashfurrow
Copy link
Member

Agreed dispatch_async isn't usually the best, but I think it works in this case.

I've run this locally and verified it works – thanks @paweldudek for such a quick turnaround on this 🙇 I'm going to defer to @jeffh on merging.

CurrentTestCaseTracker *tracker = [CurrentTestCaseTracker sharedInstance];
[[XCTestObservationCenter sharedTestObservationCenter] addTestObserver:tracker];
// XCode 7.3 introduced a bug where early registration of a test observer prevented
// default XCTest test observer from being registered. That caused no longs being printed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo longs -> logs; XCode -> Xcode

thanks for the quick PR!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Let's fix this in another PR/commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created #272 to address this 👍

@modocache
Copy link
Member

LGTM, thanks for the quick response! Normally I'd defer to @jeffh, but in the interest of unbreaking people's workflow I'll merge this now. If we ever think of a more elegant approach we can fix forward.

@modocache modocache merged commit d3ed3a3 into Quick:master Mar 25, 2016
@modocache
Copy link
Member

@paweldudek mind sending a PR to bump the Nimble submodule in Quick?

@paweldudek
Copy link
Contributor Author

@modocache looks like @ashfurrow was faster than me 😉

Megal pushed a commit to Megal/Nimble that referenced this pull request Jul 31, 2019
Fixed issue with early test observer registration preventing console output
phatblat pushed a commit to phatblat/Nimble that referenced this pull request May 3, 2020
A small typo in documentation
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

Successfully merging this pull request may close these issues.

No console output with Xcode 7.3

4 participants