Make XCTest output as pretty as `yarn`

XCTest output is unclear and feels unmodern. Any plans to make it pretty and clear as yarn test?

12 Likes

That would be cool. But is that a Swift thing? Or would that be more Xcode’s purview?

Both really. From an open source point of view, swift test's output could be greatly improved and Xcode could adopt the same approach since the output is pretty much the same. (Additionally, it would be great if Xcode filtered the stupid system os_log calls so it doesn't pollute app output, but that's an Xcode issue. Xcode's terminal is pretty terrible compared to other modern IDEs and text editors.)

You can currently use xcpretty to filter the output from Xcode (and maybe SPM) into something actually readable by humans, just not in Xcode. For example, Fastlane uses xcpretty to clean up the output into something nice. For command line builds and CI, Fastlane gives you far better output.

5 Likes

I didn't even realize that swift test was a thing! I'd best look into that...

1 Like

Just adding ways to customize the output would probably go a long way. At least then libraries like Quick & Nimble could improve that part of the experience.

2 Likes

Yep, but xcpretty is basically unmaintained and there are numerous bugs e.g. on Linux that are only fixed in forks that were never merged. Plus, xcpretty swallows any kind of useful output (e.g. in case of errors). We use it, but it's not nice.

1 Like

xcbeautify does a pretty solid job: GitHub - tuist/xcbeautify: A little beautifier tool for xcodebuild

I’ve had multiple instances (this week) where xcbeautify swallows errors that it doesn’t know how to parse. I wouldn’t recommend using it without piping the full, unmodified log somewhere you can still read it.

Fastlane does that by default but it's definitely worth of a bug report to xcbeautify. You may also want to follow their recommendations for redirecting stderr to stdout, NSUnbufferedIO=YES xcodebuild [flags] 2>&1 | xcbeautify.

2 Likes

Yeah, we were properly setup to redirect stderr to stdout - definitely worth a bug report, too, but not worth the intrusion into my CI workflow to have to roundtrip disable a prettifier just to see the actual error that caused the workflow to fail.

On CI we tee the raw logs to a file before piping to xcpretty and then cat the raw log if testing failed. I'm not really convinced this is a thing worth doing.

2 Likes