22
Design for Testability Will Iverson

Design For Testability

Embed Size (px)

DESCRIPTION

If you had an opportunity to build an application from the ground up, with testability a key design goal, what would you do? In this presentation, we will look at just such a situation - a major, two year rewrite of a suite of core business systems. We will discuss how a system looks when testability is as important as functionality - and what it looks like when quality concerns are part of the initial design. We will look at the role of test automation and manual test in a modern project, and look at the tools and processes. The session will conclude with a demo of the latest visual test automation tool from MIT and a Q&A.

Citation preview

Page 1: Design For Testability

Design for Testability

Will Iverson

Page 2: Design For Testability

Who Is This Guy?   Will Iverson

[email protected]   Check www.nukio.com for LinkedIn, Twitter, etc.

  Java since 1995   Pascal/C/C++ before that…   Apple, Symantec, Sun, BEA…

  Four books on Java   Hibernate, Web Services, Mac OS X Java, Jakarta Commons

  Today: Architect, Consultant, Manager, Coach   All Star Directories, Architect   Nukio, Coach/Trainer/Consultant

Page 3: Design For Testability

Audience Qs   Java, .NET, Other…?   Agile, Waterfall, Other…?   Who is your customer?

Page 4: Design For Testability

Basic Premise   Design should include:

  Correctness   Performance   Usability   Testability

Page 5: Design For Testability

Why Design Testability?   Care about quality of work   Want rapid feedback   Want to solve problem correctly   Want to be able to make changes without fear   Want to be a team working toward same goals!

Page 6: Design For Testability

What is Design?   Design : planning that lays the basis for making of every

object or system   Both a noun & verb

  Things you design…   Database models   System components   User interfaces   Process for adding features & fixing issues

Page 7: Design For Testability

Typical Web App Development Flow Current Software • Validate (customer, market, product management, etc.)

New Feature or Fix • What does it do?

Design • Database changes • Code

Implement • Database changes • Code

Test • Verify against requirements • Negative tests

Deploy • Validate non-functional (perf, system)

Page 8: Design For Testability

Design for Testability Current Software •  Validate (customer, market,

product management, etc.)

New Feature or Fix •  What does it do?

Design •  Tests •  Database changes •  Code

Implement •  Tests •  Database changes •  Code

Deploy •  Validate non-functional (perf,

system)

How you test & what you test informs the design!

Page 9: Design For Testability

Agile, Waterfall, Other…?   Agile

  Test Driven Development, Behavior Driven Development, Acceptance Test Driven Development

  Reality check: team dynamic?

  Waterfall   Typical: QA handed requirements, software: figure it out   Lucky: QA test plan is included in initial sign off

  Freeform   Sit in the same room, hash it out daily

Page 10: Design For Testability

Sample: Code Centric High Level Stack

Presentation •  External Web Site (Spring MVC) •  Internal Tools (Grails) •  Partner API (XML via HTTPS) •  Reporting (Jasper)

Business Logic •  Spring •  Hibernate

Database •  Data Model •  Data Set[s]

Page 11: Design For Testability

Example: Testable High Level Stack Design

Presentation •  External Web Site (Spring MVC) •  Internal Tools (Grails) •  Partner API (XML via HTTPS) •  Reporting (Jasper)

Business Logic •  Spring •  Hibernate

Database •  Data Model •  Data Set[s]

Spring Controller Tests Canoo Web Tests Selenium HTMLUnit Report Monitoring Job[s]

JUnit DbUnit Mockito (external services)

p6spy Jailer LiquiBase

How would I test and identify the resolution to any open issues?

Page 12: Design For Testability

Sample: Typical Model Design   “There are two ways of

constructing a software design. One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies.”   C.A.R. Hoare

Page 13: Design For Testability

Testable Model Design

Lead Generation Service

• 3 public interface methods

Lead Delivery Service

• 4 public interface methods

Revenue Recognition

Service • 6 public interface methods

Test this independently of everything else

Page 14: Design For Testability

Complexity Kills Services   Stateless interfaces

  Avoid complex choreography   Single request/response actions

  More than 5-8 tables? More than 5-8 classes?   Break it up

  But… it’s not complicated enough!?   Exactly.

  What about Integration Tests?   Are you testing integration, or are you testing coupled

components   Coupled components = revisit design!

Page 15: Design For Testability

Real World Examples: Decoupling By Force

  OS & Application Processes   Database Connection Recovery   Virtual Machines (Java, .NET, VMWare, etc)

  “Chernobyl-Based Design”

Page 16: Design For Testability

Test at the Right Place   Don’t test your database through the GUI   Don’t test your business logic through the GUI   You can’t test APIs (remote/distributed or traditional) via

GUI

Page 17: Design For Testability

Common Challenges   JavaScript

  You can test JavaScript via Selenium if properly implemented   Takes work & discipline

  Bad HTML   Test: can you push back on dev to get proper ids?

  Layout & Design Fidelity   Browsershots   Many hosted services

Page 18: Design For Testability

Things To Mock   Clock   3rd Party Services

  What about database interaction?

Page 19: Design For Testability

Things To Do   Someone needs to do exploratory testing

  QA background is key

  Someone needs to automate the testing   Avoid manual regression – oh, the humanity!

  Someone needs to validate with the customer   Acceptance tests?

Page 20: Design For Testability

Shameless Plug   Agile Testing

  CI, TDD   Expert JUnit   DBUnit, HTMLUnit, Selenium   Automate documentation generation

  March 25th – 26th

www.nukio.com

Page 21: Design For Testability

Bonus Finale: Sikuli

Page 22: Design For Testability

Q & A