Swift Testing tests in enum (namespace) extensions are acting strange

Using Xcode 16.1 (16B40).

When adding a test suite with tests in an extension to an enum:

  • The tests can be compiled and executed as expected (by clicking the diamond), and e.g. "Reveal in Test Navigator" works as expected. But after the tests have been executed, there is no check or cross diamond icons in the Test Navigator,

  • If I right click the empty diamond in the margin for one of the tests and click "Jump to report", Xcode shows an alert saying "No test found matching the identifier MyEnumNameSpace/SomeTests/example()", which is very strange.

Steps to reproduce:

  1. Create a new iOS app project using SwiftUI and Swift Testing.
  2. Add a file in the app target defining an enum namespace:
    public enum NamespaceDefinedInSomeApp {}
    
  3. Replace the content of the already created …Tests.swift file with:
    import Testing
    @testable import SomeApp
    
    // This works as expected:
    @Suite struct SomeTests {
      @Test func example() async throws {
        #expect(true)
      }
    }
    
    // This compiles and executes but acts strange:
    extension NamespaceDefinedInSomeApp {
      @Suite struct SomeTests {
        @Test func example() async throws {
          #expect(true)
        }
      }
    }
    
    // This compiles and executes but acts strange:
    enum AnotherNamespace {}
    
    extension AnotherNamespace {
      @Suite struct SomeTests {
        @Test func example() async throws {
          #expect(true)
        }
      }
    }
    
Answered by DTS Engineer in 817252022
Steps to reproduce:

It sounds like you’re goal is to report a bug. If so, do that using Feedback Assistant. See Bug Reporting: How and Why? for lots of hints and tips on that front.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Steps to reproduce:

It sounds like you’re goal is to report a bug. If so, do that using Feedback Assistant. See Bug Reporting: How and Why? for lots of hints and tips on that front.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Swift Testing tests in enum (namespace) extensions are acting strange
 
 
Q