Introduce timeout and after to support delayed verification.#434
Draft
sk409 wants to merge 1 commit intoBrightify:masterfrom
Draft
Introduce timeout and after to support delayed verification.#434sk409 wants to merge 1 commit intoBrightify:masterfrom
sk409 wants to merge 1 commit intoBrightify:masterfrom
Conversation
MatyasKriz
reviewed
Feb 7, 2023
| self.sourceLocation = sourceLocation | ||
| } | ||
|
|
||
| {{ container.accessibility }} init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) { |
Collaborator
There was a problem hiding this comment.
Why opt for duplicate init instead of a default parameter value?
| } | ||
|
|
||
| func atMost(_ count: Int) -> VerificationSpec { | ||
| VerificationSpec(callMatcher: Cuckoo.atMost(count), continuation: self) |
Collaborator
There was a problem hiding this comment.
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 { |
| // | ||
| // Created by Shoto Kobayashi on 03/09/2022. | ||
| // | ||
|
|
| } | ||
|
|
||
| public func check() -> Bool { | ||
| if start == nil { |
Collaborator
There was a problem hiding this comment.
Please bind start as if let start instead of using a force unwrap below.
|
|
||
| import Foundation | ||
|
|
||
| public protocol ContinuationWrapper: Continuation { |
Collaborator
There was a problem hiding this comment.
Why is this type necessary?
| public let name: String | ||
|
|
||
| private let matchesFunction: ([StubCall]) -> Bool | ||
| private let canRecoverFromFailureFunction: ([StubCall]) -> Bool |
| if matches && continuation.exitOnSuccess { | ||
| break | ||
| } | ||
| continuation.wait() |
Collaborator
There was a problem hiding this comment.
Doesn't this always wait for the full duration of the timeout even if the matcher is satisfied?
Collaborator
|
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I introduced these two global functions to support delayed verification discussed in this issue(#277).
ContinuationWithTimeoutandContinueationAfterDelayconform toContinuationprotocol.Continuationdetermines 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.