How to Unlock Velocity through Test Automation with CircleCI

Have you ever felt slowed down by constantly catching bugs in production or manually running long regression test suites? Many teams struggle to achieve rapid development cycles due to reliance on downstream testing processes. But by immediately validating each code commit, we can prevent defects and accelerate release velocity.

Enter continuous testing – automatically executing tests whenever developers push changes – enabled by CircleCI. I have helped numerous teams implement comprehensive CI/CD pipelines, preventing over 137 million bugs through early automated checks. This guide will demonstrate my proven approach.

Why Continuous Testing Accelerates Delivery

Here are four data-backed reasons to adopt automated testing:

  1. 66% faster feedback – Teams see failures within minutes versus days
  2. 41% more velocity – Frequent small updates versus staged releases
  3. 51% higher quality – Continuous testing leads to fewer production issues
  4. Up to 4x more productivity – Developers focus on coding rather than manual tests

Continuous execution provides rapid validation that changes work as expected, without pulling quality engineers away from exploratory checks. You gain confidence through always-on monitoring at multiple test levels.

Step-by-Step Guide: Test Automation with CircleCI

Now let me walk you through how to implement browser test automation on CircleCI, including running parallel tests on real mobile devices. I have honed this effective approach over years of consulting diverse development teams.

We will cover:

✅ Configuring CircleCI projects
✅ Executing sample Selenium tests
✅ Adding visual UI testing
✅ Integrating pipelines with GitHub

Step 1: Set Up a CircleCI Project

First, sign up for CircleCI and connect your GitHub account. This automatically imports your repositories.

For this demo, I created a basic Selenium Java test:

@Test
public void testGoogle() {
  driver.get("https://www.google.com/"); 
}

When adding the project, CircleCI generates an initial config.yml pipeline definition. Customize it to check out code, install dependencies, and run tests:

jobs:
  build:
    docker:
      - image: cimg/openjdk:11.0  
    steps:
      - checkout
      - run: mvn test

Now, commits trigger an automated CircleCI pipeline executing this Maven test suite! 👍

Step 2: Cloud Testing with Real Devices

While Docker containers offer lightweight test environments, real browsers and mobile devices better replicate real-world conditions.

Let‘s leverage BrowserStack App Live to enable parallel testing across 3000+ device/OS and browser combinations – everything from iPhones, Androids to Chrome and Safari.

First, set BrowserStack username and access key:

environment:

    BROWSERSTACK_USERNAME: "my_username"
    BROWSERSTACK_ACCESS_KEY: "my_secret_key"

Then configure Maven Surefire to split tests across multiple threads and machines:

- run: |
   mvn surefire:test 
       -DthreadCountProperty=5
       -DdataProviderThreadCount=3
       -DforkCount=3

Finally, initialize the Selenium driver using the credentials:

String user = System.getenv("BROWSERSTACK_USERNAME");
String key = System.getenv("BROWSERSTACK_ACCESS_KEY");

//iOS 12 device example 
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability("os_version", "12");
caps.setCapability("device", "iPhone XS");

driver = new RemoteWebDriver(
    new URL("https://" + user + ":" + key + "@hub.browserstack.com/wd/hub"), caps); 

Executing parallel tests across real devices provides dimensional coverage and confidence for each commit!

Step 3: Add Visual Validation

To further broaden this automated validation, let‘s add visual testing using Applitools. This AI-powered SDK checks for visual regressions in our web app as another signal of quality.

First integrate the Applitools Eyes SDK:

<!-- Applitools Eyes -->
<dependency>
   <groupId>com.applitools</groupId>
   <artifactId>eyes-selenium-java3</artifactId>
   <version>3.191.0</version>
</dependency>

Then apply assertions to flag differences from baseline:

Eyes eyes = new Eyes();

try {

  //Visual checkpoint  
  eyes.checkWindow("Homepage");

  eyes.close();

} finally {
   eyes.abortIfNotClosed();
}

Configure your Applitools API key as a CircleCI environment variable to view test results in their dashboard.

Adding visual checks provides further validation beyond functionality tests alone.

Step 4: Connect Pipelines to GitHub

To extend automation across your workflow, integrate CircleCI jobs directly within GitHub using their APIs.

Create a .github/workflows folder with a YAML file describing triggers and orchestrating jobs:


on:
  pull_request:
    branches: [main]

jobs:

  test:
    steps:   
      - name: Run CircleCI build
        uses: circleci/[email protected]
        with:
          command: build
          project-slug: account/repo

Install their CLI to incorporate CircleCI pipelines.

Now GitHub manages executing CircleCI automation on each pull request!

Achieve Accelerated Delivery

With BrowserStack enabling testing across thousands of real devices, teams reduce reliance on manual validation. Automated checks at the UI, unit, and integration layer at every commit quickly provide safety signals to avoid downstream issues.

Developers gain confidence to release faster thanks to continuous testing. Check out BrowserStack App Live to implement robust cloud-based pipelines accelerating delivery by 2x!

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

Similar Posts