ios – How do I consider View.physique in XCTests?

0
50


I wish to write a easy XCTest reminiscent of:

var actualCount = 0

let view = HStack {
  ForEach(0..<3) { _ in
    Textual content("Take a look at").onAppear { actualCount += 1 } 
  }
}

let _ = view.physique

XCTAssertEqual(actualCount, 3)

The issue is I get the syntax error:

error: worth of kind ‘HStack<ForEach<Vary, Int, some View>>’ has no member ‘physique’

If I attempt to wrap it in a customized View after which name .physique, it does run, but it surely would not execute the code in onAppear.

If I attempt to hold it as an HStack and get it to run by including extension View { var physique: some View { physique } }, I get a runtime error:

Deadly error: physique() shouldn’t be known as on HStack<ForEach<Vary, Int, ModifiedContent<Textual content, _AppearanceActionModifier>>>

Is there any technique to pressure the physique of a view tree to be evaluated for testing functions?