You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stubbing a throwing async function to throw an error shows a compile error:
givenSwift(await bird.canFly()).willThrow(MockError())
// Compiler error:
// Cannot convert value of type 'Mockable<ThrowingAsyncFunctionDeclaration, () async throws -> Bool, Bool>'
// to expected argument type 'Mockable<ThrowingFunctionDeclaration, () async throws -> Bool, Bool>'
If I look into the mockingbird code, it seems the function willThrow(_:) is not available for the ThrowingAsyncFunctionDeclaration (see Stubbing.swift#L399)
When stubbing a throwing async function to throw an error
Then I expect to see no compile error
And I expect the function to throw an error, whenever it is called by the test
Environment
Mockingbird CLI version: 0.17.0 (not sure why this is on 0.17.0, the resolved SPM package in Xcode has version 0.20.0)
Xcode and Swift version: 5.6
Package manager: SPM package
Unit testing framework: XCTest
Custom configuration
Mockingbird ignore files
Supporting source files
The text was updated successfully, but these errors were encountered:
I have the same issue.
But a bit different workaround works for me based on @ailtonvivaz answer.
In my case error is enum that conforms Error protocol.
It looks like:
New Issue Checklist
Overview
Stubbing a throwing async function to throw an error shows a compile error:
If I look into the mockingbird code, it seems the function
willThrow(_:)
is not available for theThrowingAsyncFunctionDeclaration
(see Stubbing.swift#L399)Example
Expected Behavior
When stubbing a throwing async function to throw an error
Then I expect to see no compile error
And I expect the function to throw an error, whenever it is called by the test
Environment
The text was updated successfully, but these errors were encountered: