-
Notifications
You must be signed in to change notification settings - Fork 174
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce timeout and after to support delayed verification. #434
base: master
Are you sure you want to change the base?
Conversation
self.sourceLocation = sourceLocation | ||
} | ||
|
||
{{ container.accessibility }} init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why opt for duplicate init
instead of a default parameter value?
} | ||
|
||
func atMost(_ count: Int) -> VerificationSpec { | ||
VerificationSpec(callMatcher: Cuckoo.atMost(count), continuation: self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me like this one and every method above it can just call the with(_:)
method, is that right?
|
||
import Foundation | ||
|
||
public class ContinueationAfterDelay: NSObject, ContinuationWrapper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo "Continueation".
// | ||
// Created by Shoto Kobayashi on 03/09/2022. | ||
// | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduntant line.
} | ||
|
||
public func check() -> Bool { | ||
if start == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please bind start
as if let start
instead of using a force unwrap below.
|
||
import Foundation | ||
|
||
public protocol ContinuationWrapper: Continuation { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this type necessary?
@@ -11,33 +11,44 @@ public struct CallMatcher { | |||
public let name: String | |||
|
|||
private let matchesFunction: ([StubCall]) -> Bool | |||
private let canRecoverFromFailureFunction: ([StubCall]) -> Bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
if matches && continuation.exitOnSuccess { | ||
break | ||
} | ||
continuation.wait() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this always wait for the full duration of the timeout even if the matcher is satisfied?
I like the API this provides, but I need some more context on the implementation before we go ahead with it. |
d2d44b9
to
a4618f6
Compare
I introduced these two global functions to support delayed verification discussed in this issue(#277).
ContinuationWithTimeout
andContinueationAfterDelay
conform toContinuation
protocol.Continuation
determines whether CallMatcher::matches should be called again, waits, etc.like this:
Users can simply write test of fire-and-forget asynchronous function and asynchronous function with completion closure that does not require argument verification.
But I think that if users want to verify completion closure argument, They should use expectation.
If users write below code, XCTAssertEqual may no be called.
This PR is a prototype.
If this PR is acceptable, I will write comments, tests and explanation to README.md.
If there are any improvements, please point them out.