GitLab CI/CD provides powerful features to run your automated tests whenever a new commit is pushed. In this guide we will look at all the steps to get your first test automation suite running with GitLab and also look at submitting & reporting test results.
It doesn't matter whether you are including your automated tests in your main GitLab project or if you prefer a separate project to host and run just your automated tests: using GitLab CI/CD is a great way to improve your test automation execution.
All you need to follow this guide is some basic understanding of GitLab and Git, so let's go!
Initial GitLab Project and CI/CD Setup
We start with creating a new project in GitLab to host your Git repository. For this guide we are creating a project called
example-gitlab-automation but you can adjust the name based on your project. We are also hosting the full project and code repository for this article on GitLab, so you can always review the full working example there. You can also follow this guide if your team is using a private GitLab instance on your own server (instead of GitLab.com as we use in our example here).
We recommend using the
git command line tool and getting familiar with it if you haven't used it before. Or you can alternatively edit and add code through GitLab's web interface.
GitLab automatically enables CI/CD pipelines for new projects. It's just a matter of adding a new configuration file called
.gitlab-ci.yml to your code repository with instructions for GitLab on what to run. So simply create the following basic workflow in your main repository directory and commit it: