I adopted this pattern years ago. Whenever I write a protocol that I expect clients to conform to, then I enclose all its tests in such generic functions in a separate module provided alongside the main one. (Same for classes that will be subclassed.) Then my actual test targets simply call the test functions for each provided concrete conformer and nothing more. That way clients can apply the same set of tests with a single line, and automatically benefit from any new regression or edge case tests that pop up over time. (And hopefully they upstream tests of their own for any gaps they discover.)
Instead of a separate related project (which is still the next‐best thing), I actually recommend pitching the idea of vending the standard and core library’s native tests in a similar manner: SwiftTestUtilities, FoundationTestUtilities, etc.