test driven development

22

Upload: samnang-chhun

Post on 06-May-2015

790 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Test Driven Development
Page 2: Test Driven Development

Email ([email protected])

Blog (http://tech.wowkhmer.com)

Rails Developer

.NET Developer

Page 3: Test Driven Development
Page 4: Test Driven Development
Page 5: Test Driven Development

About Testing!

Test Last or DDD (Design Driven Tests)

Page 6: Test Driven Development

Short development iterations

Is a design process

Based on requirement and pre-written test cases

Tests are your first users

The goal is to produce working clean code that fulfills requirements

If TDD hurts then you're doing it wrong

Page 7: Test Driven Development

Unnecessary Codes

Unchangeable Codes

Unintelligible Code

Page 8: Test Driven Development

Makes you think about required behavior.

Provides documentation.

Improves quality.

Reduces speculative code.

Less time debugging.

Confidence in change

Discover usability issues early

Page 9: Test Driven Development

I don’t have time to unit test.

The client pays me to develop code, not write unit test.

I am supporting a legacy application without unit tests.

QA and User Acceptance Testing is far more effective in finding bugs.

I don’t know how to unit test, or I don’t know how to write good unit tests.

Page 10: Test Driven Development

It forces you to really understand the code.

It forces you to really understand the tests

It forces you to create code that is truly reusable and modular and testable

These forces drive you to keep your code and your tests simple and easy to understand.

Page 11: Test Driven Development

Enabling TDD

TDD Cycle

Choosing the First Test?

Green Bar Patterns

State-based vs. Interaction-based Unit Testing

Page 12: Test Driven Development

NUnit

MbUnit

VSTS

xUnit.net

Moq

Rhino Mocks

Resharper

TDD.NET

Refactor Pro!

Visual Studio

Page 13: Test Driven Development

create a

failing

test

write

just

enough

to pass

remove

duplicatio

n clarify

intent

Page 14: Test Driven Development

RED

GreenRefactor

Page 15: Test Driven Development
Page 16: Test Driven Development

The simplest.

The essence.

If you need to write code that is untested, choose a simpler test.

If the essence approach takes to much time to implement, choose a simpler test.

Page 17: Test Driven Development

Small and focused

Intention revealing

Repeatable

Independent

Have no side-effects

Page 18: Test Driven Development

Description should be

• Domain-specific

• Suitable for customer comprehension

• Understandable in absence of code

Writing descriptions

• Think about behavior

• Think about the context of the behavior

• Focus on the words, not the implementation

Page 19: Test Driven Development
Page 20: Test Driven Development

Fake It(Til You Make It)Start with hardcoded results and wait until later tests to force them to become real.

Triangulate To AbstractionMake the code abstract only when you have two or more examples.

Obvious Implementationaka Don't Be Stupid

If you really, really, honestly know the right way to implement it, then write it that way.

Page 21: Test Driven Development
Page 22: Test Driven Development