TDD-based workflow: Optimizing Development Process

Post on 15-Apr-2017

455 views 4 download

transcript

TDD-based Workflow

Optimizing Development Process

Akbar Hidayat

Test Driven Development

1. Define Expected Behaviours2. Code them

assertEquals(10,add(4, 6)

);

function add(left, right)return left + right;

);

BUG DESTROYER?

BUG DESTROYER?

TEST NEEDS DESIGN

Feedback

BUSINESS IMPACTS

CORRECT IMPLEMENTATION

MAINTAINABLE CODE

Tests provide feedback for the quality of the

design

TDDTDD can't even be begun until we know the shape of the system that is to be created.

(Uncle Bob)

BDDThe point of BDD is to get people

communicating and bridge the gap between ‘technical’ and ‘business’ people

(Dan North)

Clean Architecture

&

DDD

Breaking it down

1. User Stories2. Scenario Explorations3. Architecture Decisions4. Writing down the test

User Story

As a [role] I want to [user need] so that [change]

User Story

1. Who2. Behavioral Change3. Business Value4. Ubiquitous Language

User Story

As an event owner I want to refund the remaining points from an event so that I can use the points again

leanpub.com/50quickideas

Architectural Decisions

TDD can't even be begun until we know the shape of the

system that is to be created.

(Uncle Bob)

Think how the code flow

/** * @expectedException InvariantException * @expectedExceptionMessage EVENT.REFUND.STILL_ACTIVE */function given_that_an_event_has_not_finished_and_when_the_event_is_being_refunded_then_it_should_fail(){

$eventRefund->refund($event, $requester);}

/** * @test */function given_that_the_event_is_sponsored_and_when_it_has_been_refunded_then_the_remaining_point_should_be_returned_to_the_admin(){

...}

/** * @test */function refunding_a_sponsored_event_should_increase_admin_point(){

// Simulating HTTP POST to a certain route$this->post(‘/refundedevents’, [

‘id’ => 212 ]);

// Check in Database that the admin point has increased...

}

Documentation of what the SUT does

Documentation of how it does it

DECODEIDEASDISCOVER POTENTIAL