Automation Testing with CI using Bitbucket
Before diving into the use of Bitbucket in CI automation testing. Let’s discuss what is Continuous Integration(CI)?
Continuous Integration is a DevOps software development practice 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.
After understanding what is continuous integration, lets now play with the dark side of the force(QA), by asking some questions.
Do you validate your test code? Do you run automated testing with each change?
If not 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.
- 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:
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 follow these steps and make automation testing with CI using Bitbucket yourself.