# How do I apply the same test suite to two different target objects?

**URL:** <https://forums.swift.org/t/how-do-i-apply-the-same-test-suite-to-two-different-target-objects/34326>\
**Category:** Using Swift\
**Tags:** xctest\
**Created:** [March 4, 2020, 9:59pm UTC](https://forums.swift.org/t/how-do-i-apply-the-same-test-suite-to-two-different-target-objects/34326 "2020-03-04T21:59:21Z")\
**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:** [March 4, 2020, 10:15pm UTC](https://forums.swift.org/t/how-do-i-apply-the-same-test-suite-to-two-different-target-objects/34326/2 "2020-03-04T22:15:30Z")

</div>

I recommend some variation on this:

> [@Swift-checkit: A library for validating common protocol semantics](https://forums.swift.org/t/swift-checkit-a-library-for-validating-common-protocol-semantics/33741/2):
>
> 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 te…

---

_[View the full topic](https://forums.swift.org/t/how-do-i-apply-the-same-test-suite-to-two-different-target-objects/34326)._
