Designing a preventive strategy

With Isolated and Integrated tests

Aritz Águila Díaz

About me

Community

Work

@duiraritz

Aritz Águila Díaz

Co-organizer

Owner

Head of QA

Quality Engineer

Present

Former

  1. A bit of context
     
  2. Isolated & Integrated differences
     
  3. Isolated code examples
     
  4. Pros & Cons of each type
     
  5. When to use each in our strategy

What are we going to talk about 

Reactive Strategy

Find bugs strategy

This makes testing not entirely efficient and affects team productivity.

Preventive Strategy

Preventive bugs strategy

Isolated tests

Preventive Strategy

Three pillars

Productivity

Defect
prevention

Adaptability

  1. A bit of context
     
  2. Isolated & Integrated differences
     
  3. Isolated code examples
     
  4. Pros & Cons of each type
     
  5. When to use each in our strategy

What are we going to talk about 

Tests that require a real communication or integration with other collaborator.

Integrated tests

Integrated tests types

  • Integration tests.
     
  • Functional or E2E tests.
     
  • Performance tests.
    ...

Possible problems

Poor traceability

Poor feedback

Flaky tests

Long testing time

Tests that don't require a real communication or integration with other collaborator.

Isolated tests

Isolated tests types

  • Unit tests.
     
  • Contract tests.
     
  • Integration tests.
     
  • Functional or E2E tests.
     
  • Performance tests.
    ...
  1. A bit of context
     
  2. Isolated & Integrated differences
     
  3. Isolated code examples
     
  4. Pros & Cons of each type
     
  5. When to use each in our strategy

What are we going to talk about 

The App

The App Code

SUT architecture

Nobel prize storage app

Uncouple Back - Front
testing

Back contract tests

package prizes.getPrizes.successfully

import org.springframework.cloud.contract.spec.Contract

Contract.make {
  request {
    method('GET')
      url('/nobel_prizes/v1/')
  }
  response {
    status OK()
  ...

Contract

Consumer

Provider

Ensure that the sent or received message complies with the agreed conditions

Consumer & Provider isolated testing

Conditions

Front isolated testing

Nobel prize front

version: "3.1"
services:
  stubs:
    image: spring-cloud-contract-stub-runner:2.1.2.RELEASE
    environment:
      - STUBRUNNER_IDS=...infrastructure:+:stubs:9876
      - STUBRUNNER_STUBS_MODE=LOCAL
    volumes:
      - ~/.m2:/root/.m2
      ...

Docker-compose stub runner

E2E test

context('Navigation', () => {
  it('search a nobel prize by category and years', () => {
    const category = 'physics'
    const from = '2018'
    const to = '2019'

    cy.get('[data-test=search-category]').type(category
    ...
  })
})

Front e2e tests

  • No deployment needed.
     
  • No external collaborator needed.
  • Reduced test time.
     
  • Early stage feedback.

Back isolated testing

version: "3.1"

services:
  back_test_web:
    depends_on:
      - back_test_db
      - back_test_wiremock
    build:
      dockerfile: ./src/e2eTest/resources/docker/Dockerfile
    ...

Docker-compose

@Test void
should_get_nobel_prizes() {

  //Call to api first time
  given()
  .when()
  .contentType(ContentType.JSON)
  .get(nobelPrizesApiUrl)
  .then()
  .statusCode(200);

  ...
}

E2E test

  • No deployment needed.
     
  • No external collaborator needed.
     
  • Reduced test time.
     
  • Early stage feedback.

Back e2e tests

TKiero

Isolated SUT architecture

Nobel prize storage app

  1. A bit of context
     
  2. Isolated & Integrated differences
     
  3. Isolated code examples
     
  4. Pros & Cons of each type
     
  5. When to use each in our strategy

What are we going to talk about 

Isolated

Integrated

  • Poor feedback.
  • Poor traceability.
  • Flaky tests.
  • Long testing time.
  • More tech knowledge.
  • Not launched through a real environment.
  • Launched through a real environment.
  • Poor feedback.
  • Poor traceability.
  • Flaky tests.
  • Long testing time.
  1. A bit of context
     
  2. Isolated & Integrated differences
     
  3. Isolated code examples
     
  4. Pros & Cons of each type
     
  5. When to use each in our strategy

What are we going to talk about 

Both are complementary.

 

Balanced and defined test strategy based on product requirements.

 

Use for acceptance and regression tests in a development stage in order to get a quick feedback.

Isolated tests

Use as support in order to get a more complete quality status.

Integrated tests

Based on test confidence

Based on test time

Based on test flakiness

Q&A

time

Thanks!!

Designing a preventive strategy - With Isolated & Integrated tests

By Aritz Águila

Designing a preventive strategy - With Isolated & Integrated tests

  • 1,437