-
1.
TechTalks #1 Unit Testing and Test-Driven Development Duong Trong Tan [email_address] Hanoi, 9- 2011
-
2.
Objectives <ul><li>Why testing? </li></ul><ul><li>Introduction to unit testing </li></ul><ul><li>Unit testing in Java with JUnit </li></ul><ul><li>What is Test-Driven Development? </li></ul><ul><li>How can TDD improve quality? </li></ul><ul><li>TDD practices and guidelines. </li></ul>Unit Testing and Test-Driven Development
-
3.
Unit Testing and Test-Driven Development CRISIS Numbers: 4.4 million cars recalled Billions of $ loss. Damage the brand
-
4.
Desire vs. Reality Unit Testing and Test-Driven Development gap Requirement esign Desired Implementation Reality testing
-
5.
Why testing? <ul><li>Ensuring QUALITY </li></ul><ul><li>Managing RISKS </li></ul><ul><li>Optimizing Return-On-Investment (ROI) </li></ul><ul><li>Professionalism </li></ul>Unit Testing and Test-Driven Development
-
6.
Typical Production model Unit Testing and Test-Driven Development
-
7.
Bug cost Unit Testing and Test-Driven Development
-
8.
Balancing Unit Testing and Test-Driven Development GOOD FAST CHEAP
-
9.
Testing level <ul><li>Unit testing </li></ul><ul><ul><li>On individual unit of source code (function, class, etc.) </li></ul></ul><ul><ul><li>Smallest testable part </li></ul></ul><ul><ul><li>Developer testing </li></ul></ul><ul><li>Integration testing </li></ul><ul><ul><li>On groups of modules </li></ul></ul><ul><li>System testing </li></ul><ul><ul><li>On complete integrated system </li></ul></ul>Unit Testing and Test-Driven Development
-
10.
JUnit <ul><li>Unit testing automation framework for Java </li></ul><ul><li>Can do integration test </li></ul><ul><li>Integrated in IDEs (Eclipse, NetBeans, IntelliJ, etc.) </li></ul><ul><li>Must have tool for Java developers </li></ul>Unit Testing and Test-Driven Development http://www.junit.org/
-
11.
Test-Driven Development <ul><li>You don’t start programming until you have designed your tests! </li></ul><ul><li>Strategy </li></ul><ul><ul><li>Make it Fail </li></ul></ul><ul><ul><ul><li>No code without a failing test </li></ul></ul></ul><ul><ul><li>Make it Work </li></ul></ul><ul><ul><ul><li>As simply as possible </li></ul></ul></ul><ul><ul><li>Make it Better </li></ul></ul><ul><ul><ul><li>Refactor(code, design, test, documentation) </li></ul></ul></ul><ul><ul><li>Believe in testing </li></ul></ul>Unit Testing and Test-Driven Development
-
12.
Suggested TDD Unit Testing and Test-Driven Development
-
13.
Thinking changed <ul><li>Design or code must be TESTABLE </li></ul><ul><li>“ Error Message ” is a good news </li></ul><ul><li>Courage </li></ul><ul><li>Simple </li></ul><ul><li>Agile </li></ul>Unit Testing and Test-Driven Development
-
14.
How to do TDD <ul><li>Design </li></ul><ul><ul><li>Use [simple] design , figure out what to do </li></ul></ul><ul><ul><li>[Then .. create the skeleton first] </li></ul></ul><ul><li>Test </li></ul><ul><ul><li>Write test that reflect the design </li></ul></ul><ul><ul><li>All tests should FAIL </li></ul></ul><ul><li>Implement </li></ul><ul><ul><li>Write the code </li></ul></ul><ul><li>Test </li></ul><ul><ul><li>All tests should PASS </li></ul></ul>Unit Testing and Test-Driven Development
-
15.
TDD live demo <ul><li>Application: simplified Calculator </li></ul><ul><li>Language: Java </li></ul><ul><li>Tools used: </li></ul><ul><ul><li>NetBeans 7 </li></ul></ul><ul><ul><li>JUnit </li></ul></ul><ul><ul><li>Task board (Excel) </li></ul></ul><ul><ul><li>Whiteboard (for simple design) </li></ul></ul>Unit Testing and Test-Driven Development
-
16.
Red-Green-Blue model Unit Testing and Test-Driven Development
-
17.
Refactor to Clean Code <ul><li>Readable </li></ul><ul><li>Maintainable </li></ul><ul><li>Changeable </li></ul>Unit Testing and Test-Driven Development
-
18.
Acceptance Test-Driven Development Unit Testing and Test-Driven Development ATDD: team collaboration, a kind of cross-functionality Requirement Automated Acceptance Tests TDD Definition Of Done
-
19.
Acceptance TDD (ATDD) <ul><li>3D strategy </li></ul><ul><li>D iscuss in requirement workshop </li></ul><ul><ul><li>To make tests library </li></ul></ul><ul><li>D evelop in concurrence </li></ul><ul><ul><li>To create more Passed features </li></ul></ul><ul><li>D eliver for acceptance </li></ul><ul><ul><li>To meet DONE definition, accepted by users </li></ul></ul>Unit Testing and Test-Driven Development
-
20.
Supporting system: CI Unit Testing and Test-Driven Development
-
21.
Q&A Unit Testing and Test-Driven Development
-
22.
Further reading Unit Testing and Test-Driven Development
-
23.
Tools <ul><li>JUnit : http://junit.org </li></ul><ul><li>FitNesse : http://fitnesse.org / </li></ul><ul><li>RoBotFramework: http ://code.google.com/p/robotframework / </li></ul><ul><li>Hudson CI : http://hudson-ci.org / </li></ul><ul><li>SVN : http://subversion.tigris.org / </li></ul>Unit Testing and Test-Driven Development
-
24.
Unit Testing and Test-Driven Development Thank you! <ul><li>Meet Tấn DT: </li></ul><ul><li>TechTalks </li></ul><ul><li>HanoiScrum.net </li></ul><ul><li>Slideshare.net/duongtrongtan </li></ul><ul><li>Facebook: Duong Trong Tan </li></ul><ul><li>[email_address] </li></ul>
I don’t want to frustrate you by bunch of testing terms. Just focus on thinking, process and how-tos.
Global: 4.4 million cars recalled (http://wsws.org/articles/2010/feb2010/toyo-f12.shtml ) In the first quarter of 2009, the company posted a $7.7 billion loss. The estimated loss for Toyota in the current financial year, calculated before the expansion of the recall process in January, is $5.5 billion. http://parttimembadegree.com/business-school-cases/toyota-recalls-pr-management-crisis/ http://en.wikipedia.org/wiki/2009%E2%80%932011_Toyota_vehicle_recalls VN: “mua toy cho nó lành” – lost
For ROI optimization, see the analysis of Rex Black on Managing the Testing Process: Practical Tools and Techniques for Managing Hardware and Software Testing
In conclusion: Test a.s.a.p Testing is responsibilities of all including developers.
Introduced in XP
Design (simple) first => draft solution => Design criteria: testable
Refactor, clean code frequently
What is acceptance test? fist