TDD – Example Code – What should we do?



TDD – Example Code – What should we do?

0 0


angular-presentation


On Github bryzaguy / angular-presentation

Composition Over Layers

Tests driving your design.

TDD

Unit testing, red-green-refactor.

Test Doubles

Stub, spy, mock, fake.

Classic vs Mockist TDD

Example Code

Service Spec

Ctrl Spec

What should we do?

Layers

Requires test doubles, unclear roles.

Current State

  • Service tests url that returns data
  • Controller all about order data

Let's Refactor

Same behavior, different arrangement.

Strategy: Push Promise Out

Skinny controller, null object pattern.

Add Order Model

Order can care about its own data.

Order Model

Refactored Code

Service Spec

Ctlr Spec

Order Spec

Results

First Specs

Refactored Specs

Better design

Driven by tests.

Questions?