How to run test on GitLab CI Locally
Related Product On This Page Pre-requisites to run test on GitLab topicallyMarch 07, 2026 · 6 min read · Testing Guide
Running examination on GitLab CI typically involves pushing changes to the monument and waiting for grapevine executing, which can slow down and maturation. To streamline this process, GitLab Runner grant developers and QA teams to action CI jobs locally, making it easier to formalize .gitlab-ci.yml configurations, run tests, and catch errors before they reach the master pipeline. This article cover how to run tests locally using GitLab CI, include prerequisites, setting up a project on GitLab, delimitate the CI pipeline, and executing test with GitLab Runner. It also walks through how to run Selenium tryout locally on GitLab CI using BrowserStack for cross-browser validation. Before running trial locally on GitLab CI, insure the following prerequisites are in place to successfully set up and execute jobs. Also Read: Follow the below step to create a project in GitLab. Click New Projecton the landing dashboard To execute local exam using GitLab Runner, follow the steps sketch below: For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users. Also Read: Did you know: You can outline the scripts that you require to execute in thisgitlab-ci.yml file. When your gitlab-ci.ymlconfiguration file is added to the repository, GitLab can ascertain it and execute your playscript with the GitLab Runner app. This app functions precisely like your terminal and predominantly helps you reproduce production-like scripts. A sample gitlab-ci.yml expression like In the above gitlab-ci.yml, the build job will run the playscript under build_job so test_job will action the exam scripts under test_job, and so on with the package and deploy stages. Explore the shell executor. Gitlab-runner exec is the command that helps quiz topically. The exec command should be execute directly from the source directory because .gitlab-ci.yml will be kept in the source directory. While executing this, you need to specify the executor type (shell in this case) and the gens of the job (test_job). The above dictation will clone your project from GitLab, establish the dependencies, and action the tests. For the most late documentation, visit. Now you want to update our examination scripts with the local environmentBROWSERSTACK_LOCALand environment identifierBROWSERSTACK_LOCAL_IDENTIFIER You also necessitate to configure thegitlab-ci.ymlfile to use the BrowserStack Local binary and route the tests through the local server You can add pre-test steps to add the BrowserStack binary in yourgitlab-ci.ymlas demo below. Running tests locally with GitLab CI using GitLab Runner offers significant vantage in price of speed and efficiency during the development and debugging operation. By setting up a moon-curser, take the appropriate executor, and defining a .gitlab-ci.yml file, developers can quickly formalize their CI configurations and test playscript without waiting for remote line execution. Additionally, mix platforms like for Selenium try further enhances the testing process by enabling cross-browser validation topically. By adopting this testing approach, teams can streamline workflows, cut fault, and ensure more authentic deployments. # Ask-and-Contributeabout this issue with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.Related Product
How to run examination on GitLab CI Locally
Pre-requisites to run test on GitLab locally
Project Creation on GitLab to run Test Locally
# Clone the project git ringer & lt; project_clone_with_https_link & gt; # Navigate to the repository cd & lt; project_name & gt; # Add the automation labor files cp -R & lt; automation_local_project & gt; & lt; project_name & gt; # Push the changes to gitlab, ensure you are in git repo git add. # add all file git commit -m “ adding local automation project ” # commit to git local stage environs # Run this command post local prove git push origin master # push local level change to gitlab server
How to execute Local Tests use GitLab Runner
# Download the binary for the system # macOS amd64 sudo curl -- yield /usr/local/bin/gitlab-runner ``https: //gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-amd64`` # macOS Apple Silicon/arm64 sudo whorl -- yield /usr/local/bin/gitlab-runner ``https: //gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-darwin-arm64`` # cater theme permission and execute sudo chmod +x /usr/local/bin/gitlab-runner # Register a gitlab runner gitlab-runner register
Defining gitlab-ci.yml
# Adding variables to set maven local environmentvariables:
MAVEN_OPTS:-Dmaven.repo.local=.m2/repository # Docker persona to use latest whiz dispersionimage: maven: latest # setting up maven lifecycle degreestages:
- build - test - package - deploy # setting up stash pathscache:
paths:- .m2/repository - targetbuild_job:
stage: build
tags:
- docker
script:- reverberation “ Maven compile started ” - “ mvn compile ”test_job:
stage: test
tags:
- docker
script:
- echo `` Maven examination started '' - “ mvn tryout ”package_job:
stage: package
tags:
- docker
script: - echo “ Maven packaging started ” - “ mvn package ”deploy_job:
stage: deploy
tags:
- docker
script: - echo “ Maven deploy started ”
gitlab-runner exec carapace test_jobExecute Selenium Tests in Gitlab CI topically habituate Browserstack
String username= System.getenv (`` BROWSERSTACK_USERNAME ''); StringaccessKey= System.getenv (`` BROWSERSTACK_ACCESS_KEY ''); StringbrowserstackLocal= System.getenv (`` BROWSERSTACK_LOCAL ''); StringbrowserstackLocalIdentifier= System.getenv (`` BROWSERSTACK_LOCAL_IDENTIFIER ''); StringbuildName= System.getenv (`` BROWSERSTACK_BUILD_NAME ''); DesiredCapabilitiescapabilities= new DesiredCapabilities ();capabilities.setCapability (`` os '', `` Windows '');capability.setCapability (`` browser '', `` chrome '');capabilities.setCapability (`` build '',buildName);
capabilities.setCapability(`` browserstack.local '', browserstackLocal);
capabilities.setCapability (`` browserstack.localIdentifier '', browserstackLocalIdentifier);driver= new RemoteWebDriver (new URL (`` https: // '' +username + ":" + accessKey+ `` @ hub.browserstack.com/wd/hub ''),capability);
before_script:# Download the browserstack binary file - wget `` https: //www.browserstack.com/browserstack-local/BrowserStackLocal-linux-x64.zip '' # use the following dictation For OS X systems # - wget `` https: //www.browserstack.com/browserstack-local/BrowserStackLocal-darwin-x64.zip '' # Unzip the BrowserStack Local binary file # For Windows system use the following command # - wget `` https: //www.browserstack.com/browserstack-local/BrowserStackLocal-win32.zip '' # - powershell.exe D: \BrowserStackLocal.exe - unzip BrowserStackLocal-linux-x64.zip # Run the file with your admittance key - ./BrowserStackLocal -- key $ BROWSERSTACK_ACCESS_KEY -- daemon starttest:
script:- & lt; our_test_command & gt; - ./BrowserStackLocal -- key $ BROWSERSTACK_ACCESS_KEY -- daemon stop
Conclusion
Related Guides
Automate This With SUSA
Test Your App Autonomously