Created
April 6, 2020 17:35
-
-
Save andreacipriani/bc0b2e0e0736d339b29ab70de84fca35 to your computer and use it in GitHub Desktop.
Show the problem of testing an async function in Tuist
This file contains 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
class Subject { | |
let dependency: Dependency | |
func doSomethingAsync() { | |
DispatchQueue.main.async { | |
dependency.doSomething() | |
} | |
} | |
} | |
final class SubjectTests: XCTTestCase { | |
func testDoSomethingAsync_callsDependency() { | |
let fakeDependency = FakeDependency() | |
let subject = Subject(dependency: fakeDependency) | |
subject.doSomethingAsync() | |
XCTAssertEqual(fakeDependency.doSomethingCallCount, 1) // It will fail because the implementation is async | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment