Created
September 21, 2023 18:35
-
-
Save davbeck/bb6e7b2301a9669f6fd241982233c30b to your computer and use it in GitHub Desktop.
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
// example of what the macros could be expanded into for XCTestCase | |
final class PostsCoordinatorTests: XCTestCase { | |
func test_addPost() async throws { | |
let coordinator = PostsCoordinator() | |
coordinator.createPost() | |
XCTAssert(coordinator.postCount == 1) | |
} | |
func test_hasExistingPosts_countsPosts() async throws { | |
let coordinator = PostsCoordinator() | |
coordinator.posts = [ | |
.build(), | |
.build(), | |
.build(), | |
] | |
XCTAssert(coordinator.postCount == 3) | |
} | |
func test_hasExistingPosts_addPost() async throws { | |
let coordinator = PostsCoordinator() | |
coordinator.posts = [ | |
.build(), | |
.build(), | |
.build(), | |
] | |
coordinator.createPost() | |
XCTAssert(coordinator.postCount == 4) | |
} | |
} |
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
#Describe(PostsCoordinator.self) { | |
// code in describe and context gets re-run for each test | |
let coordinator = PostsCoordinator() | |
#Test("add post") { | |
coordinator.createPost() | |
#expect(coordinator.postCount == 1) | |
} | |
#Context("has existing posts") { | |
coordinator.posts = [ | |
.build(), | |
.build(), | |
.build(), | |
] | |
#Test("counts posts") { | |
#expect(coordinator.postCount == 3) | |
} | |
#Test("add post") { | |
coordinator.createPost() | |
#expect(coordinator.postCount == 4) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment