![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4958326/fbmeta.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4682088/maxresdefault-3.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671349/rocketScience_xxltn.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671353/navwin.gif)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671354/ie55.gif)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671396/houses-and-paws-whimsical-dog-house.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671397/avon-6-x-8-double-door-shiplap-apex-shed-913.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671398/one-story.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671399/486c4697-2784-4d77-875f-107f7a5f13bf.c10.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671484/17596179_1733727810271001_484741296200613888_n.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671400/CPA_Building_2.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671401/Building.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671409/35B01C59-EF38-4E5E-ABBA-64E36051400B_cx0_cy11_cw88_w1023_r1_s.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671410/series-of-tower-building.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671404/fcd82d27b05615b0a42428fca5b67548.jpg)
Stockholm syndrome
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671396/houses-and-paws-whimsical-dog-house.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671500/building-foundation.jpg)
"Premature optimization is the root of all evil"
Donald Knuth
When testing makes no sense
Miro Svrtan
@msvrtan
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671651/Website-Responsive-WordPress-BootStrapTheme.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671654/aHR0cDovL3d3dy5zcGFjZS5jb20vaW1hZ2VzL2kvMDAwLzAwOS84Mjkvb3JpZ2luYWwvY3VyaW9zaXR5LW1hcnMtcm92ZXItcGFpbnRpbmcuanBn.jpeg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671651/Website-Responsive-WordPress-BootStrapTheme.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671631/Nexus-5_with_android_logo-56a401095f9b58b7d0d4e6af.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671636/Apple-iPhone7-Plus-Gold-1-3x.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671643/microsoft-office-screenshot-01.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671639/img_nbg-418n-v2_main_600.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671640/u_10140689.jpg)
When should we write tests?
High cost to fix?
Cost of fixing > cost of testing
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671651/Website-Responsive-WordPress-BootStrapTheme.jpg)
When it brings "value"
Value = benefit - cost
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671288/vincent_farm_blog.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671289/tomatoes_aug08_631.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671286/maxresdefault.jpg)
Fallacy #1:
It makes my project more expensive
Do you charge for manual testing?
Bugs cost too
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4628344/Opel_Astra_2015_Hatchback_Header_944x550_as16_e01_233.jpg)
Ask for forgiveness, not permission
Fallacy #2:
It takes a lot of time
learning != using
Fallacy #3:
It takes extra time
Manual testing takes time as well
Fallacy #4:
ship PoC to production
Feature lifecycle
Phase 1: Exploration
Phase 2: Modelling/architecture
Phase 3: Development
Phase 4: Production
Fallacy #5:
100% code coverage
class User
{
...
function isAdmin() : bool{
return $this->admin;
}
...
}
Fallacy #6:
writing tests later is OK
class User
{
...
function shouldChargeVat() : bool{
if($this->isCompany()){
return false;
}
return true;
}
...
}
Fallacy #7:
we have "tests"
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4677068/lumbergh_office_space_lg.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4677023/maxresdefault-2.jpg)
Fallacy #8:
TDD has something to do with testing
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671267/Screen_Shot_2018-03-06_at_09.15.51.png)
Fallacy #9:
TDD all the way
Easier onboarding
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672135/flpsrcornhaklqffkocn.jpg)
Easier to add new features
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672135/flpsrcornhaklqffkocn.jpg)
class User
{
...
function shouldChargeVat() : bool{
if($this->isCompany()){
return false;
}
return true;
}
...
}
class User
{
...
function shouldChargeVat() : bool{
if(true === $this->isCompany()){
if('SRB' === $this->country){
return true;
}else{
return false;
}
}
return true;
}
...
}
Easier refactoring
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672135/flpsrcornhaklqffkocn.jpg)
class User
{
...
function shouldChargeVat() : bool{
if(true === $this->isCompany()){
if('SRB' === $this->country){
return true;
}else{
return false;
}
}
return true;
}
...
}
class User
{
...
function shouldChargeVat() : bool{
if('SRB' === $this->country){
return true;
}
if(true === $this->isCompany()){
return false;
}
return true;
}
...
}
class User
{
...
function shouldChargeVat() : bool{
if('SRB' === $this->country){
return true;
}
if(true === $this->isCompany()){
return false;
}
return true;
}
...
}
class User
{
...
function shouldChargeVat() : bool{
if(true === $this->isCompany()){
if('SRB' === $this->country){
return true;
}else{
return false;
}
}
return true;
}
...
}
Easier rewriting
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672135/flpsrcornhaklqffkocn.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4953736/compiling.png)
Cleaner code
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672135/flpsrcornhaklqffkocn.jpg)
It's hard to test
shitty code
Small app
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672136/x-mark-red-hi.png)
One off app
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672136/x-mark-red-hi.png)
Exploration phase
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672136/x-mark-red-hi.png)
Job security
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4672136/x-mark-red-hi.png)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671277/Pasture-raised-chickens.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671283/new-york-state-office-general-services-metrology-food-lab-pp1017-laboratory.jpg)
![](https://s3.amazonaws.com/media-p.slid.es/uploads/75324/images/4671278/20170923_USP001_0.jpg)
Thank you!
@msvrtan
Questions?
@msvrtan
\When testing makes no sense
By Miro Svrtan
\When testing makes no sense
PHP Srbija 2018, May 26th 2018
- 1,729