Tests in the Same Repo or a Separate One? Pros and Cons

Where should end-to-end tests live: next to the source code, or in their own repository? It’s one of the first questions you hit when you start with E2E, and neither answer is free.

Below I go through both setups and what each one does to a team. I’ll tell you which one I usually pick, but you still have to decide for your own project. Short version: keep E2E tests in the project repository when developers and test engineers work as one team, and use a separate repository when the tests are written by people outside the app team.

Storing tests in the project repository

Keeping tests in the application repository means app code, tests, tasks and workflows all sit in one place. A developer can run everything without hunting for commands in another repo. That also closes the gap between developers and test engineers (SDETs). Nobody has to ask for access to “the other” codebase.

Ownership shifts too. When a test fails on a developer’s branch, fixing it is that developer’s job. You don’t end up chasing someone to unblock a merge, or repairing tests after every failure yourself.

Versions stay in sync as well. Say the newest feature changes the application flow and breaks some tests. The developer fixes the tests on the same branch and pushes one working change. There is no moment when the tests don’t match the latest version of the app.

Example structure

<application-repository>/<root>/app
<application-repository>/<root>/tests

Storing tests in a separate repository

When the tests live in another project and they break, developers usually won’t care. Maintaining them and unblocking the pipeline becomes your job.

Separation also cuts collaboration. If your organization already draws a line between developers and test engineers, a separate repository makes that line wider. Each side stops touching the other’s work. I think that’s the wrong direction. Developers and test engineers should work on both the application code and the tests, as one team.

Look at it from the developer’s side. You built a feature and it breaks a few tests. You want to merge it fast. Either you switch to the other repository, fix the tests and open a second pull request, or you merge with failing tests. You can’t merge both changes at the same time, so the versions drift apart.

There are upsides. Each repository gets a workflow that fits it. The application has tasks to build and run the app. The tests repository has jobs that set up the app under test and execute the suite. Someone starting on one project sees only what belongs to it, and that’s easier to navigate day to day.

The cost is more moving parts. Running the whole flow on a local machine is annoying, because you execute commands in two places. Onboarding a new developer takes longer than when everything is in one repo.

One clarification: a separate tests repository doesn’t mean it’s the only one with tests. The application still has its own. Developers should write unit tests next to the source code and run them in the pipeline.

Example structure

<application-repository>/
<tests-repository>/

Project repository vs separate repository: summary

Project repository Separate repository
Ownership Shared across the team Falls to test engineers
Versions of app and tests Change in one pull request Can drift apart
Local setup One checkout Two repositories to run together
Onboarding Faster Slower
Repository focus Mixed Each one only what it needs
Fits best Developers and test engineers on one team No in-house test engineers, or tests shared by many apps

Project repository

  • Raises ownership across the team.
  • Closes the gap between developers and test engineers.
  • Tests and application versions stay in sync, so there are no merge problems between them.
  • Everything related to the app and the tests is in one place.

Separate repository

  • Lowers ownership across the team.
  • Widens the gap between developers and test engineers.
  • Tests can fall behind the newest application version.
  • Cleaner repositories, each with only what it’s concerned about.

After reading the lists, a single repository looks like the clear winner. That’s how it has worked for me most of the time. It doesn’t make it right for you. It depends on your project architecture, company structure, team size and how your test engineers work.

Talk to your teammates and decide together. I also assumed you have in-house test engineers. If you don’t, a separate repository for the tests is probably the better choice.

The repository choice is one of several structural decisions. For the others (data, environments, reporting, ownership), see six things to consider when designing a test architecture. Where the tests live also decides how they run in the pipeline, which I cover in CI/CD and parallelisation. If you are starting from zero, begin with your first steps in test automation.