38
7/25/09 CodeAndroid Meetup – Learning about the Platform IE Singapore – The Little Red Dot 30th May 2009 10 AM

Test Driven Development

Embed Size (px)

DESCRIPTION

Slides by Wade Mealing

Citation preview

Page 1: Test Driven Development

7/25/09

CodeAndroid Meetup– Learning about the Platform

IE Singapore – The Little Red Dot30th May 200910 AM

Page 2: Test Driven Development

7/25/09

CodeAndroid meet up

Test Driven Development

Page 3: Test Driven Development

7/25/09

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

Page 4: Test Driven Development

7/25/09

Apologies upfront:

Easily excitedTalk fastAustralian accentLarge area to explainQuestions, Slow down

Page 5: Test Driven Development

7/25/09

Today:Unit Testing

Page 6: Test Driven Development

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

Page 7: Test Driven Development

7/25/09

Unit Testing is intended to:

verify software behavior

Page 8: Test Driven Development

7/25/09

Unit Testing is intended to:

verify software behavior

using software

Page 9: Test Driven Development

7/25/09

Independent code

that test or verify

larger sections of code

Page 10: Test Driven Development

7/25/09

Software developers are quite often :-

Developers

Page 11: Test Driven Development

7/25/09

Software developers are quite often :-

DevelopersTesters

Page 12: Test Driven Development

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality Assurance

Page 13: Test Driven Development

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality AssuranceDocumentation

Page 14: Test Driven Development

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality AssuranceDocumentation

Support

Page 15: Test Driven Development

7/25/09

Software developers are quite often :-

DevelopersTesters

Quality AssuranceDocumentation

SupportNinjas

Page 16: Test Driven Development

7/25/09

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

Why not automate it ?

Page 17: Test Driven Development

7/25/09

You're thinking “I already spend all day 

coding!”

Page 18: Test Driven Development

7/25/09

But 

Page 19: Test Driven Development

7/25/09

Unit testing reduces issues created during 

development and and maintenancemaintenance

Page 20: Test Driven Development

7/25/09

Yes, you will end up writing more code 

during development.

Page 21: Test Driven Development

7/25/09

Why more code ?

Design

Facilitates change

Simplifies integration

Documentation

Page 22: Test Driven Development

7/25/09

Design

The “API”

Specifies form and behavior without internal details

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

Page 23: Test Driven Development

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.

Page 24: Test Driven Development

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.

Page 25: Test Driven Development

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.

Page 26: Test Driven Development

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

Page 27: Test Driven Development

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

Page 28: Test Driven Development

7/25/09

Maintenance “cost” is less.  

Page 29: Test Driven Development

7/25/09

Nobody can agree on the cost of software 

maintenance.

Page 30: Test Driven Development

7/25/09

You will never catch all bugs.

Page 31: Test Driven Development

7/25/09

Adequate test coverage will catch the nasty ones.

Page 32: Test Driven Development

7/25/09

Testing wont improve your code.

Page 33: Test Driven Development

7/25/09

But the code you create will have less surprises

Page 34: Test Driven Development

7/25/09

Testing on Android

Page 35: Test Driven Development

7/25/09

If you read this, you survived the live demonstration.

Page 36: Test Driven Development

7/25/09

Additional informationin samples apiDemos

Page 37: Test Driven Development

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.

Page 38: Test Driven Development

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