Isolated & Integrated tests
A mindset change
Aritz Águila Díaz
About me
Community

Work

@duiraritz




Aritz Águila Díaz
Co-organizer
Owner
Head of QA
Quality Engineer
Now
-
A bit of context
-
What are the differences
-
Isolated code examples
-
Pros & Cons
- When to use each
What are we going to talk about
Strategy inheritance
Testing has evolved alongside software development but we still apply "traditional" strategies.
Reactive Strategy
Dev reactive flow example




This makes testing not entirely efficient and affects team productivity.
Preventive Strategy
Preventive dev flow example


Isolated tests

-
A bit of context
-
What are the differences
-
Isolated code examples
-
Pros & Cons
- When to use each
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.
...
-
A bit of context
-
What are the differences
-
Isolated code examples
-
Pros & Cons
- When to use each
What are we going to talk about

The App
SUT architecture

Nobel prize storage app

Back isolated testing
Nobel prize storage service



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

- First step: API definition.
- TDD approach.
- Parallel development of the client and the service.
- Controller tests.

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



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.



Isolated SUT architecture
Nobel prize storage app


-
A bit of context
-
What are the differences
-
Isolated code examples
-
Pros & Cons
- When to use each
What are we going to talk about
Isolated
Integrated
Poor maintainability.Poor traceability.Flaky tests.Long testing time.
- More tech knowledge.
- Not launched through a real environment.
- Launched through a real environment.
- Poor maintainability.
- Poor traceability.
- Flaky tests.
- Long testing time.
-
A bit of context
-
What are the differences
-
Isolated code examples
-
Pros & Cons
- When to use each
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!!
Isolated & Integrated tests - A Mindset change
By Aritz Águila
Isolated & Integrated tests - A Mindset change
We will see the difference between integrated and isolated tests. Theory and code.
- 1,644