Isolated & Integrated tests
A mindset change
Aritz Águila Díaz
About me
Community
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6668501/3VDklrsX_400x400.jpg)
Work
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6668520/pasted-from-clipboard.png)
@duiraritz
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6668550/NQA.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6668554/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6668573/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6668575/pasted-from-clipboard.png)
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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6747249/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6747264/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6747265/pasted-from-clipboard.png)
![](https://media1.giphy.com/media/ReImZejkBnqYU/giphy.gif)
This makes testing not entirely efficient and affects team productivity.
Preventive Strategy
Preventive dev flow example
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6747352/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6747264/pasted-from-clipboard.png)
Isolated tests
![](https://media0.giphy.com/media/11sBLVxNs7v6WA/giphy.gif)
-
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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6694867/pasted-from-clipboard.png)
Integrated tests types
- Integration tests.
- Functional or E2E tests.
- Performance tests.
...
Possible problems
Poor traceability
Poor feedback
Flaky tests
Long testing time
![](https://media3.giphy.com/media/11StaZ9Lj74oCY/giphy.gif)
Tests that don't require a real communication or integration with other collaborator.
Isolated tests
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6695462/pasted-from-clipboard.png)
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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739385/pasted-from-clipboard.png)
The App
SUT architecture
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6738701/pasted-from-clipboard.png)
Nobel prize storage app
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
Back isolated testing
Nobel prize storage service
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739358/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
![](https://media2.giphy.com/media/27Y1W0GCKQtDq/giphy.gif)
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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
- First step: API definition.
- TDD approach.
- Parallel development of the client and the service.
- Controller tests.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739667/pasted-from-clipboard.png)
version: "3.1"
services:
back_test_web:
depends_on:
- back_test_db
- back_test_wiremock
build:
dockerfile: ./src/e2eTest/resources/docker/Dockerfile
...
Docker-compose
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
@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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739675/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739680/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739685/pasted-from-clipboard.png)
Front isolated testing
Nobel prize front
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739362/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
![](https://media1.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif)
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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
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.
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739675/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739709/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6739667/pasted-from-clipboard.png)
Isolated SUT architecture
Nobel prize storage app
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6738810/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/6736848/pasted-from-clipboard.png)
-
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.
![](https://media0.giphy.com/media/3o751VsrGnRBZRqxEI/giphy.gif)
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
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/7197672/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/7197677/pasted-from-clipboard.png)
Based on test time
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/7197677/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/7197683/pasted-from-clipboard.png)
Based on test flakiness
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/7197677/pasted-from-clipboard.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/1156913/images/7197689/pasted-from-clipboard.png)
Q&A
time
![](https://media2.giphy.com/media/QAsBwSjx9zVKoGp9nr/giphy.gif)
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,508