Agile Software Testing - Agilogy - Voxel.pdf

jordi.pradel 9 views 43 slides Jun 21, 2024
Slide 1
Slide 1 of 45
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45

About This Presentation

Agile software development patterns and strategies for the busy agile software developer.


Slide Content

Agile Automated Testing
Jordi Pradel

Jordi Pradel Miquel
Software developer
Interested in agility, quality, backend,
functional programming, ...
- 2005: Founder of Agilogy
- 2014, 2016: Father of 2
- 2020: Amateur violinist

Agile software testing
Goals
Desiderata
Technical concepts
Patterns
Strategy

Goals
No Bugs!
detection & prevention

Desiderata

Principles
•Usability to better testing!
•Determinism !
•Welcoming to change !
•User friendliness !
•Quality, quality, quality!
•Economy !

Deterministic tests
Flaky tests
Avoid. Flaky. Tests.

Deterministic tests
Isolate tests from
•Execution order
•Concurrency
•External systems
•The alignment of stars

Tests that (allow you to) welcome change
Don't be in the way of refactoring
outcome, not behavior
Changes, changes, changes!
cohesion

User friendly tests
•Clear error reporting
•Fast!
•Maintainable test code

Economics of testing
•How to prioritize?
•How to design?

Technical concepts
(aka buzzwords)

Black box vs white box

Broad stack tests
vs
Narrow tests

Test doubles
Dummy
Fake
Mocks, stubs and spies

Mocks vs Spies
Stubs

Unit tests
developer-centric
small
fast
https://martinfowler.com/bliki/UnitTest.html

Integration tests

A very gentle
introduction to
Hexagonal
Architecture

Hexagonal architecture
Application
(domain)
driven sidedriving side
Driving
adapter
Driving
adapter
Driven
adapter
Driven
adapter
Driving
port
Driving
port
Driven
port
Driven
port
(aka Controllers)
(aka use cases / services)
(aka repository / api proxy
interfaces)
(aka repository / api proxy
implementations)

Hexagonal architecture
Example
Application
(domain)
driven sidedriving side
RulesEngineController
RulesEngineRepository
VppApiProxy
RulesEngineService
IRulesEngineRepository
IVppApiProxy
VppApi
Payments
(PostgreSql)

Driving adapters
(aka controllers)
•Low level implementation of APIs, listeners, etc to get commands, queries
or events from the outside to the driving ports in the hexagon.

Driving adapters (controllers)
Dependency Injection

Driving ports
(aka services, use cases, interactors)
•Domain interface of the app used by the driving adapters to pass
commands, queries and events in the language of the domain.

Driven ports
(aka repositories, api proxies)
•Domain abstraction of the capabilities of external systems used by the
application.

Driven adapters
(aka data sources)
•Low level implementation of the interfaces of driven ports that use
specific external services or technologies (e.g. a PostgreSql database).

Driven Adapters
Decouple driven ports from technology used: Exceptions
!

Patterns

Arrange, Act, Assert
Stateless components

AAA with state
Stateful components
1. Arrange inputs & initial state
2. Act
3. Assert outputs & final state
https://blog.agilogy.com/2022-06-17-testing-and-persistent-state.html

In-memory
production-ready
test fakes
" fast!
" deterministic
# may fail
# implementation cost

In-memory production-ready test fakes
Alternatives
•Test in integration with Isolated, production(-like) external systems
•" You test the actual component
•# Slow
•Use mocks and stubs
•# You test the behaviour of the system, not the outcome

Isolated,
production(-like)
external systems
" real
# slow

Strategy

Test all the domain
Broad test of all the components that
form the domain
•Whole domain
•Through (driver) ports (controllers)
•Use AAA with state

A.Test with In-memory,
production-ready test fakes
(preferred)
B.Test in integration with
Isolated, production(-like)
external systems (slower)
Test all the domain
alternatives

Narrow tests of
complex logic
•unit tests
•AAA / AAA with state
•only a bunch of these!

Integration tests of
driven adapaters
•integration tests
•isolated, production-like
external systems
•in isolation
•AAA with state

Test Driver
Adapters
A.behavior with Mocks and
stubs
B.outcome with the actual
domain + doubles

Test the assembly with end-to-
end tests

Test test fakes
Make In-memory, production-ready
tests fakes production-ready indeed:
•Parameterize Integration tests
•Run the same test suite for both

Invest!
A couple examples...

Clear error
reporting

Property-based
testing with shrinking

Property-based testing with shrinking