Xcode Cloud UI test plans : show attachment previews in test results

Hi everyone,

In the Apple overview page of Xcode Cloud, I can see this image of the result of a test executed with Xcode Cloud:

The attachements of the test are displayed as a full image. But on my side, the attachements are displayed inline and not as a full image preview. I can still QuickLook them but they are always collapsed.

I created an extensions of XCTestCase to easily generate screenshot attachements for my UI tests:

extension XCTestCase {
    /// Take a screenshot of a given app and add it to the test attachements.
    /// - Parameters:
    ///   - app: The app to take a screenshot of.
    ///   - name: The name of the screenshot.
    func takeScreenshot(of app: XCUIApplication, named name: String) {
        let screenshot = app.windows.firstMatch.screenshot()
        let attachment = XCTAttachment(screenshot: screenshot)
        #if os(iOS)
        attachment.name = "Screenshot-\(name)-\(UIDevice.current.name).png"
        #else
        attachment.name = "Screenshot-\(name)-macOS.png"
        #endif
        attachment.lifetime = .keepAlways
        add(attachment)
    }
}

And use it like so on my UI Test:

final class LocalizationTests: XCTestCase {
    override class var runsForEachTargetApplicationUIConfiguration: Bool {
        true
    }

    func testLaunchScreen() throws {
        let app = XCUIApplication()
        app.launch()

        takeScreenshot(of: app, named: "Launch")
    }
}

Here is also my test plan configuration:

There are a lot of WWDC sessions about Xcode Cloud and unit testing, but I couldn't find one of them that talks about this feature. Maybe I'm missing something really obvious, but this feature would be a super nice addition to my workflow. I'm using Xcode 14.1 (14B47b) and macOS Ventura 13.0.1 (22A400).

Does anyone know if it is possible to replicate the behavior showed on the Apple website? Thanks in advance for your help.

Thanks for your reply. I already read this documentation, but I did it again in case I missed something. And I did, I forgot to turn on "Localization Screenshots". But it didn't solved my problem. I followed this part of the documentation step by step but my screenshots are still presented inline and not as shown on the Apple Website

Hello! This seems to be describing a kind-of-hidden feature of the Xcode test results viewer called Gallery mode.

From the Assistant dropdown, you can navigate to Gallery mode if you are looking at a test result inside Xcode.

See the attached screenshot below with the menu item highlighted. It's in the top right of the center panel.

Xcode Cloud UI test plans : show attachment previews in test results
 
 
Q