Automation Testing with CI using Bitbucket – Everything you need to know about BitBucket
Before diving into the use of Bitbucket in CI automation testing, let’s discuss Continuous Integration(CI).
Continuous Integration is a DevOps software development practise where developers often join their code changes into a central repository and test the changes.
The main goal of continuous integration is to find and investigate bugs more quickly and improve the quality of code and software. It reduces the time it takes to validate and releasing new updates.
Do you validate your test code or do you run automated testing with each change?
If you don’t, then Bitbucket Pipelines allows to easily add the famous Continuous Integration and help in running automation testing each time we make any changes, So let’s get started.
Here are the steps:
- Open your test project.
- Now create the following file: bitbucket-pipelines.yml at the root of the project.
- After that set the continuous integration settings of your choice.
- However what I’ve been using lately, is the following configuration:
Bitbucket Pipelines uses Docker containers as an environment for your build steps. Although by default, it uses an image with Ubuntu, but this image does not contain ruby, so we need to specify an image that meet our needs.
You can use any image from DockerHub, in my case I’m using the image:
Where it is already configured with ruby, google chrome, and chrome driver.
Next, we need to specify scripts that we want to run. For our current needs we perform:
. bundle install . rubocop . bundle exec cucumber -p dev -p chrome_headless
Where first it installs all the gems of the project and its dependencies through the bundle install.
Then runs the rubocop to verify that the best practice is the syntax of the code. To make sure that there are no errors of unused variables, duplicate methods, etc.
And finally, it runs all tests in the development environment using chrome headless.
With the bitbucket-pipelines.yml file gets configured and ready to use, simply commit and push your project into the master.
After that access your project in bitbucket, and click the pipeline menu in the sidebar.Now the script will run automatically after some changes. Even after that if you go to the page and the pipeline doesn’t appear to run, just click the enable button.
Most importantly, this bitbucket-pipelines.yml file could be created directly in your project’s bitbucket pipeline tab. Hence, you must follow these steps and make automation testing with CI using Bitbucket yourself.