Search code examples
testingautomationrepositoryautomated-testsfunctional-testing

Automation testsuite in source code repository or separate repository?


I think the best practice would be to maintain the test suite in the same repo as the source code to keep the tests in sync with the code changes. But what if the infrastructure or the coding policy doesn't allow adding irrelevant files to source code? Is there a better way to keep sync between both code and tests by having a separate repo for testsuite? Thanks in advance


Solution

  • I think it depends on your goal/team and project. I have worked in both of the models and I found advantages and disadvantages of working with both.

    Automation in the same repository:

    Advantages:

    • You can share the code and element locators(for example with Espresso), so it is easy to maintain
    • It is easy for the developers to help with the maintenance (in case they want/have to)
    • It is more visible for developers to do the code review and check the PRs
    • Shared knowlodged about the code and tests between Devs and QAs
    • Devs can accidentally break automation code (but if qas are doing reviews this should be rare)
    • Test automation will have the same language as the development code

    Disadvantages:

    • You can share code, so if you have a function with a bug and you are using the same function on your tests, your tests are going to have a bug as well
    • QAs can accidentally break development code (but if devs are doing reviews this should be rare)
    • E2E tests between projects will not make sense since the tests are placed in a repo of one project and having integration with others
    • E2E tests between projects will need to have mocks to test scenarios on the other products/projects otherwise, as said above, it won't make sense to have the test project in a project repo
    • Can't share code/functions between projects as it will be confusing to have a test project sharing functions with other test projects in different repos (Unless you create a test repo with these shared functions) + you may have a test automation coded in javascript for the web project and for the mobile project you are going to have the same code as the development team, which could be different from the web, like kotlin or swift

    Automation in separated repository:

    Advantages:

    • You can share the code between test projects
    • You will reduce the maintenance cost as the project can be shared between different platform projects
    • Test automation can have the language that is more known for the team who is going to code or the language which has more advantages when maintaining the code between projects in different platforms

    Disadvantages:

    • Not really visible for the developers as they might not follow
    • You can proper create an E2E tests involving all the projects in different platforms without mocking them
    • It is not a big motivation for the developers to follow and maintain the test automation

    Anyway, I may be missing something, but I just tried to remember all the key points. In the end the team should decide this together as this again depends if the developers are going to maintain the tests as well and if you are going to perform e2e tests with or without the need of mocking the other projects