---
title: "Why you should co-locate your Xcode tests"
description: "Xcode projects with unit tests commonly separate implementation and test files into two directories, often mirroring the source structure in the tests directory. The post argues that this arrangement creates maintenance overhead, slows navigation, obscures how well-tested a codebase is when browsed or reviewed, and can leave tests with lower coding standards. It proposes co-locating each unit-test file beside its implementation file while retaining the test target association, accepting more files per directory in exchange for clearer relationships and easier movement between code and tests. The same SwiftLint configuration is used for implementation and test code, treating tests as first-class code. Tests without a single-file correspondence, including integration or UI tests, should remain in separate directories and may warrant separate targets; the authors say their codebase has adopted the style."
---

# Why you should co-locate your Xcode tests

[Kickstarter](https://yomu.fyi/company/kickstarter) · Brandon Williams · Mar 23, 2017

**Type:** Problem & solution

## Summary

Xcode projects with unit tests commonly separate implementation and test files into two directories, often mirroring the source structure in the tests directory. The post argues that this arrangement creates maintenance overhead, slows navigation, obscures how well-tested a codebase is when browsed or reviewed, and can leave tests with lower coding standards. It proposes co-locating each unit-test file beside its implementation file while retaining the test target association, accepting more files per directory in exchange for clearer relationships and easier movement between code and tests. The same SwiftLint configuration is used for implementation and test code, treating tests as first-class code. Tests without a single-file correspondence, including integration or UI tests, should remain in separate directories and may warrant separate targets; the authors say their codebase has adopted the style.

## Context

Xcode projects with unit tests commonly use separate implementation and test directories, often with a mirrored file structure. The post identifies maintenance overhead, difficult navigation, less visible test coverage during code browsing and pull-request review, and lower coding standards for tests as drawbacks of this arrangement.

## Approach / What changed

Co-locate unit-test files with their corresponding implementation files while keeping each test associated with its existing test target. Use the same SwiftLint configuration for implementation and test code. Keep tests that cover multiple files, such as integration or UI tests, in separate directories, potentially with their own target separate from unit tests.

## Takeaways

- Co-locating unit tests makes the corresponding implementation easier to find and makes navigation between the two files more direct.
- The test files remain associated with the test target even after moving into the same directory as implementation files.
- Integration and UI tests that do not correspond to a single implementation file should remain in a separate directory and may use a separate target.

**Tags:** [Architecture](https://yomu.fyi/topic/architecture), [iOS](https://yomu.fyi/topic/ios), [Testing](https://yomu.fyi/topic/testing)

- Source: [Kickstarter](https://medium.com/kickstarter-engineering/why-you-should-co-locate-your-xcode-tests-c69f79211411)
- Source URL: https://medium.com/kickstarter-engineering/why-you-should-co-locate-your-xcode-tests-c69f79211411
- Ingested by Yomu: 2026-08-30T12:07:21.822Z

[Read original post](https://medium.com/kickstarter-engineering/why-you-should-co-locate-your-xcode-tests-c69f79211411)
