-
-
Notifications
You must be signed in to change notification settings - Fork 906
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
How to test is function is called or not? #773
Comments
A few months ago let expectation = QuickSpec.current.expectation(description: "my function was called")
expectation.fulfill() When testing a closure, this is fairly simple. However if you need to test a function that is called internally, you can do a couple of things.
You can checkout the original PR for this here: #645 |
Crude Example: // protocol definition
protocol NetworkServiceHandling {
func perform(request: FetchRequest)
}
// concrete instance
final class NetworkService: NetworkServiceHandling { }
// mock instance
final class MockNetworkService: NetworkServiceHandling {
internal var expectation: XCTestExpectation?
func perform(request: FetchRequest) {
expectation?.fulfill()
}
} |
I have read some threads about it, but the thing is that I'm getting the message I am using carthage and the resolved version is So, seems like By the way, I am using Swift. |
Ahh... you're right. That API was added in October and the 1.2 release was in September. I know with pods you could just point directly to a tag, branch, etc... I'm not that familiar with Carthage, but perhaps @ikesyo can help you here. |
@shaps80 according to the project versioning, the latest released version is the one I am currently using: https://github.com/Quick/Quick/releases/tag/v1.2.0 So, if that API was added in October, why it is not released yet? Is Thanks in advance. |
Because no release has occurred since v1.2 AFAIK. It does look like it got merged into develop though. So if you point to develop you should be able to get access to that API. Sent with GitHawk |
Git it, thanks. I pointed it to |
Is there any way to test if a function is called?
When using
XCTest
framework directly, this can be tested using expectations.I have seen some code samples using booleans with an initial value as
false
and the setting them astrue
when calling the related functions but I don't like this approach.I wonder if there is an expectation-like option available in
Quick
.The text was updated successfully, but these errors were encountered: