Alexandru Bolboaca - Unit Testing from the Trenches
-
Upload
mozaic-works -
Category
Business
-
view
920 -
download
5
Transcript of Alexandru Bolboaca - Unit Testing from the Trenches
![Page 1: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/1.jpg)
Unit Testing From The Trenches
Alexandru BolboacaAlexandru BolboacaV1.0, because I embrace changeV1.0, because I embrace change
![Page 2: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/2.jpg)
I write tests because I don't want this to happen
![Page 3: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/3.jpg)
...and I don't want to be this guy
![Page 4: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/4.jpg)
Agenda
Some clarifications
5 practical ideas
Answers to your questions
![Page 5: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/5.jpg)
Clarification #1: What is a unit test?
A piece of code that checks a unit from the system under test (SUT)
A unit = a class (basic)A unit = a behavior (advanced)
![Page 6: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/6.jpg)
A unit test
AssertAssertActAct
ArrangeArrange GivenGivenWhenWhenThenThen
![Page 7: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/7.jpg)
Clarification #2: Types of tests
![Page 8: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/8.jpg)
Clarification #3: When we write tests
Design, Code, Test = Test After
Design, Test, Code = Test First Programming
Test, Code, Design = Test Driven Development
![Page 9: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/9.jpg)
Clarification #4: Who writes the tests
Technology-facing tests: Devs
Business facing tests: Analysts and Devs
Critique tests: Testers and Devs
![Page 10: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/10.jpg)
Clarification #5: Good unit tests
SimpleFast
ReadableIndependentRepeatableEasy to run
![Page 11: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/11.jpg)
Clarification #6: Write tests for any tech
… … including bash scriptingincluding bash scripting
![Page 12: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/12.jpg)
Anything else to clarify?
![Page 13: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/13.jpg)
5 Practical Ideas
![Page 14: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/14.jpg)
Situation #1
Cost: 12 hrs of businessCost: 12 hrs of businessCause: “a time calculation that was Cause: “a time calculation that was
incorrect for the leap year”incorrect for the leap year”
![Page 15: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/15.jpg)
Practical Idea #1
The The immune systemimmune system of your product of your product
![Page 16: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/16.jpg)
Situation #2
Large proportion of tests that are:
SlowUnpredictable
![Page 17: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/17.jpg)
Practical Idea #2
![Page 18: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/18.jpg)
Situation #3
I measure the development timeI measure the development timeI want the unit test coverage to be 90%I want the unit test coverage to be 90%
![Page 19: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/19.jpg)
Practical Idea #3
Managers measure Running Tested Features
Developers measure coverage
Guideline: Coverage must increase
![Page 20: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/20.jpg)
Situation #4
We have unit tests, BUT:
We extensively use the debugger
Unit tests are based on test plans
Testers still execute repeatedly manual test plans
![Page 21: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/21.jpg)
Practical Idea #4Use automated developer tests to:
Executable Specifications
Replace debugging
Complement learning
Replace repetitive manual testing
![Page 22: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/22.jpg)
Situation #5
![Page 23: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/23.jpg)
Practical Idea #5
![Page 24: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/24.jpg)
Wrap up
I measure RTF/sprintI measure RTF/sprint
![Page 25: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/25.jpg)
Alexandru Bolboaca
@alexboly, alexbolboaca.ro
● Trainings: Unit Testing, TDD, Legacy Code
● Technical Mentoring, Coaching, on-site and remote
![Page 26: Alexandru Bolboaca - Unit Testing from the Trenches](https://reader033.fdocuments.us/reader033/viewer/2022052618/554fb588b4c90586258b541d/html5/thumbnails/26.jpg)
Questions
The important thing is not to stop questioningThe important thing is not to stop questioning