This is from an Xcode generated file.
var values: [String] = []
let exp = Expectation()
let c = pub.filter { $0 != nil }.map { $0! }.sink(
The second line gives an error: "'Expectation' cannot be constructed because it has no accessible initializers". My best guess that Expectation objects come from some other Apple Swift Testing function, but I don't know where.
It’s better to reply as a reply, rather than in the comments; see Quinn’s Top Ten DevForums Tips for this and other titbits.
So I have to convert the Expectation initializers with
#expectcalls, right.
Honestly, I’m not sure what you’re actually trying to do here. In general:
-
If you want to test synchronous and asynchronous Swift routines, use the
#expectmacro. For example:@Test func example() async throws { #expect(calculateAnswer() == 42) #expect(await calculateAnswerAsync() == 42) }See Expectations and confirmations for more on that.
-
If you want to test asynchronous stuff that’s not a simple async routine, use a confirmation. See Testing asynchronous code.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"