Test Driven Development

Preview:

DESCRIPTION

Slides by Wade Mealing

Citation preview

7/25/09

CodeAndroid Meetup– Learning about the Platform

IE Singapore – The Little Red Dot30th May 200910 AM

7/25/09

CodeAndroid meet up

Test Driven Development

7/25/09

ObjectivesUnderstand the basics of unit testingCreate a unit test.Run the unit test on the emulator.

7/25/09

Apologies upfront:

Easily excitedTalk fastAustralian accentLarge area to explainQuestions, Slow down

7/25/09

Today:Unit Testing

7/25/09

“The fundamental problem with program maintenance is that fixing a defect has a 

substantial (20­50 %) chance of introducing another defect.”

Mythical Man Month

7/25/09

Unit Testing is intended to:

verify software behavior

7/25/09

Unit Testing is intended to:

verify software behavior

using software

7/25/09

Independent code

that test or verify

larger sections of code

7/25/09

Software developers are quite often :-

Developers

7/25/09

Software developers are quite often :-

DevelopersTesters

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality Assurance

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality AssuranceDocumentation

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality AssuranceDocumentation

Support

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality AssuranceDocumentation

SupportNinjas

7/25/09

If you are going to have todo it anyway...

Why not automate it ?

7/25/09

You're thinking “I already spend all day 

coding!”

7/25/09

But 

7/25/09

Unit testing reduces issues created during 

development and and maintenancemaintenance

7/25/09

Yes, you will end up writing more code 

during development.

7/25/09

Why more code ?

Design

Facilitates change

Simplifies integration

Documentation

7/25/09

Design

The “API”

Specifies form and behavior without internal details

Adequate “coverage” of the API allows confidence in code changes

7/25/09

Facilitate Change

Confidence in refactoring code quickly.

Determine original functions work when new features are added.

Verifiable tests take away guess work when changing code.

7/25/09

Simpler IntegrationThird party libraries can be “swapped” with minimal pain.

Upgrades and dependencies can be changed and proven.

Third parties can be held responsible for their bugs.

7/25/09

DocumentationTests may not explain why your code works, but it shows how you expect it to.

Tests meta data can be used to supplement existing documents.

A form of “knowledge” transfer for new team members.

7/25/09

“The fundamental problem with program maintenance is that fixing a defect has a 

substantial (20­50 %) chance of introducing another defect.”

Mythical Man Month

7/25/09

“The fundamental problem with program maintenance is that fixing a defect has a 

substantial (20­50 %) chance of introducing another defect.”

Mythical Man Month

7/25/09

Maintenance “cost” is less.  

7/25/09

Nobody can agree on the cost of software 

maintenance.

7/25/09

You will never catch all bugs.

7/25/09

Adequate test coverage will catch the nasty ones.

7/25/09

Testing wont improve your code.

7/25/09

But the code you create will have less surprises

7/25/09

Testing on Android

7/25/09

If you read this, you survived the live demonstration.

7/25/09

Additional informationin samples apiDemos

7/25/09

CodeAndroid.org

• Android Developer/User Group

• Grassroots effort by developers

• Promote Android development around this region (SEA, Oceania)

• You can join us on Facebook, Twitter (codeandroid), IRC (#codeandroid @ irc.freenode.net)

Special thanks to Google for the venue and food.

7/25/09

“The fundamental problem with program maintenance is that fixing a defect has a 

substantial (20­50 %) chance of introducing another defect.”

Mythical Man Month