7 Clean Architecture Patterns Practices Principles m7 Slides

Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

Testable Architecture

Matthew Renze
SOFTWARE CONSULTANT

@matthewrenze www.matthewrenze.com
Overview Test-Driven Development
Test Automation Pyramid
Pros and Cons
Demo
The Current State of Testing

Very little testing Not enough time


Ineffective testing Not my job
Inefficient testing It’s too hard
Test-Driven Development

Red

Refactor Green
Test-Driven Development

Red
1. Create a failing test
2. Get the test to pass
3. Improve the code Refactor Green
Test-Driven Development

Comprehensive suite of tests Red

Drives testable design


More maintainable
Refactor Green
Eliminates fear
Types of Tests

Unit tests
Functional tests Automated tests
Integration tests
Acceptance tests Semi-automated
Component tests
Smoke tests tests
Service tests
Exploratory tests Manual tests
UI tests
Test Automation Pyramid
Manual
Tests

UI
Tests

Service Tests

Unit Tests
Test Automation Pyramid
Manual
Tests

UI

Number of tests
Tests
Cost

Service Tests

Unit Tests
Acceptance Tests

Manual
Tests
Verify functionality
Language of the business UI
Tests
Criteria for completeness
Acceptance
Full tests are problematic Service Tests
Tests

Unit Tests
Acceptance Tests

Presentation

Cross-Cutting
Acceptance Tests
Eliminate user interface

Mock Services
Application
Eliminate database
Domain

Concerns
Eliminate dependencies
In-memory Mock
Persistence Infrastructure
Database Services
Acceptance Tests

Focus on the essential


Acceptance Tests
Minimize coded UI tests

Mock Services
Application
Smoke test instead
Domain
Minimize manual tests
In-memory Mock
Exploratory test instead Database Services
Why Create Testable Architecture?

Manual
Tests

Pros
UI
Easier to test Tests

Improves design
Service Tests
Eliminates fear

Unit Tests
Why Create Testable Architecture?

Pros Cons
Easier to test Higher up-front cost
Improves design TDD requires discipline
Eliminates fear Requires team buy-in
Setup
Show SaleTests (Top)
Show SaleTests (Tests)
Show CreateSaleCommandTests (Top)
Show CreateSaleCommandTests (SetUp)
Show CreateSaleCommandTests (Add)
Show CreateSaleCommandTests (Save)
Show CreateSaleCommandTests (Notify)
Show CreateSaleCommandTests (End)
Show CreateASale Feature Tests
Show CreateASale Steps
Wrap Up
Summary Test-Driven Development
Test Automation Pyramid
Pros and Cons
Demo
Test Automation Pyramid
Manual
Tests

UI
Tests

Service Tests

Unit Tests
Unit Tests

Manual
Tests

Verify a unit of code


UI
Creates seams in code Tests

Mock out dependencies


Service Tests
Test in isolation

Unit Tests
Service Tests

Manual
Tests
Verify functionality
Set of services UI
Tests
Covers service code
Tested in isolation Service Tests

Unit Tests
UI Tests

Manual
Tests

Verify full functionality


UI
High cost Tests

Very brittle
Service Tests
Should be minimal

Unit Tests
Manual Testing

Manual
Tests

Test by hand
UI
Most expensive Tests

Use where appropriate


Service Tests
Automate to free up testers

Unit Tests
Test Automation Pyramid
Manual
Tests

UI
Tests

Cost
Service Tests

Unit Tests
Acceptance Tests

Manual
Tests
Verify functionality
Language of the business UI
Tests
Criteria for completeness
Full tests are problematic Service Tests

Unit Tests
Acceptance Tests

Eliminate user interface


Acceptance Tests

Cross-Cutting Concerns
Eliminate database

Mock Services
Application
Eliminate dependencies
Domain
Minimize coded UI tests
Persistence Infrastructure
Minimize manual tests
In-memory Mock
Database Services

You might also like