# Swift-checkit: A library for validating common protocol semantics

**URL:** <https://forums.swift.org/t/swift-checkit-a-library-for-validating-common-protocol-semantics/33741>\
**Category:** Related Projects\
**Created:** [February 12, 2020, 3:32pm UTC](https://forums.swift.org/t/swift-checkit-a-library-for-validating-common-protocol-semantics/33741 "2020-02-12T15:32:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![SDGGiesbrecht](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/sdggiesbrecht/32/4768_2.png) [@SDGGiesbrecht](https://forums.swift.org/u/SDGGiesbrecht)\
**Post date:** [February 12, 2020, 7:28pm UTC](https://forums.swift.org/t/swift-checkit-a-library-for-validating-common-protocol-semantics/33741/2 "2020-02-12T19:28:16Z")

</div>

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.

---

_[View the full topic](https://forums.swift.org/t/swift-checkit-a-library-for-validating-common-protocol-semantics/33741)._
