際際滷

際際滷Share a Scribd company logo
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 side
driving 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 side
driving 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
speci
f
ic 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 &
f
inal 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

More Related Content

Agile Software Testing - Agilogy - Voxel.pdf