Unexpected Test Report Output with Selective Testing

Hey folks :waving_hand: I’m seeing some unintuitive/unexpected output for the Tuist Test Report, both in the GitHub PR integration, and on the tuist.dev dashboard. First I’ll describe exactly what I’m seeing, then I’ll add some code context in case it helps identify what’s going wrong.

My GitHub Actions CI runs two tuist test commands, one for macOS and one for iOS. When I disable selective testing, I see results that make sense to me (there are 2 iOS tests including 1 UI test and 1 unit test, and 499 macOS unit tests sounds roughly right):

However, when I reenable selective testing:

To me it is expected that only the 1 iOS UI test would run since I’m not specifying a -destination and that behavior is documented. But I would expect to see 1 Skipped iOS test and 499 Skipped macOS tests, rather than indicating there are just no tests at all.

The Tuist dashboard is consistent with the Tuist Run Report on GitHub in both cases - here’s with selective testing disabled:

And again with selective testing reenabled:

So I suppose first off, is this behavior unexpected? It’s unintuitive to me as it feels like selective test hits should fall under “Skipped” and not be omitted from the reports.

My Scheme definitions are split across a few files for organizational reasons, but this is how the Mono-Workspace-macOS is defined, which at the end of the day is a Tuist Scheme.scheme with a buildAction and a testAction, using targets (as opposed to testPlans).

// CFScheme.swift

public struct CFScheme: Codable {
  public let name: CFSchemeName
  public let buildTargetReferences: [CFTargetName]
  public let testTargetReferences: [CFTargetName]

  public init(
    name: CFSchemeName,
    buildTargetReferences: [CFTargetName],
    testTargetReferences: [CFTargetName]
  ) {
    self.name = name
    self.buildTargetReferences = buildTargetReferences
    self.testTargetReferences = testTargetReferences
  }
}

// CFScheme+MonoWorkspacemacOS.swift

public extension CFScheme {
  static var monoWorkspacemacOS: CFScheme {
    let allTargets = [CFTargetGroup].mono.flatMap(\.targets)
    let macOSTargets = allTargets.filter { $0.destinations == .macOS }

    let buildTargets = macOSTargets.map(\.name)
    let testTargets = macOSTargets
      .filter { $0.product == .unitTests || $0.product == .uiTests }
      .map(\.name)

    return CFScheme(
      name: "Mono-Workspace-macOS",
      buildTargetReferences: buildTargets,
      testTargetReferences: testTargets
    )
  }
}

// CFScheme+Tuist.swift

import ProjectDescription

public extension CFScheme {
  var tuistValue: Scheme {
    Scheme.scheme(
      name: name.rawValue,
      buildAction: .buildAction(
        targets: buildTargetReferences.map { .target($0.rawValue) }
      ),
      testAction: .targets(
        testTargetReferences.map { .testableTarget(target: .target($0.rawValue)) }
      )
    )
  }
}

I should have understood/clarified that, when selective testing is on, if I make a widespread code change, it does seem like selective testing never runs any tests. In other words, it’s not just the visual output of the run report; it seems that for me, selective testing just doesn’t run anything.

I’d have expected the change to cause tests to run again. Could you reproduce this in a project created with tuist init by any chance?