Skip to content

Instantly share code, notes, and snippets.

@ptoffy
Last active June 20, 2025 09:45
Show Gist options
  • Save ptoffy/92bbdb61c84425400c4b8d802e6ad1e0 to your computer and use it in GitHub Desktop.
Save ptoffy/92bbdb61c84425400c4b8d802e6ad1e0 to your computer and use it in GitHub Desktop.
Swift Testing Migration Utilities
replace: func test(.*)\(\)
with: @Test func test$1()
Credit to @adam-fowler
replace: XCTAssertNil\((.*)\)
with: #expect($1 == nil)
replace: XCTAssertNotNil\((.*)\)
with: #expect($1 != nil)
replace: (try\s+)?XCTAssertEqual\((.*),\s*([^,]+)\)
with: #expect($2 == $3)
replace: XCTAssertNoThrow\((.*)\)
with: #expect(throws: Never.self) { $1 }
replace: XCTAssertThrowsError\((.*)\)
with: #expect(throws: (any Error).self) { $1 }
replace: XCTFail
with: Issue.record
replace: XCTUnwrap\((.*)\)
with: #require($1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment