TESTINGbuildingCULTURE
View Slide
THIS IS NOTABOUT TDD!
@ordepdev
First of allWhy testing?
“It’s time for softwaredevelopers to take up themantle of responsibilityfor what they produce.
Testing is theengineering rigour ofsoftware development.
Responsibility— the state or fact of beingaccountable or to blame forsomething.
Rigour— the quality of being extremelythorough and careful.
SoftwareEngineering
An engineering disciplinethat is concerned withall aspects of softwareproduction.
MUCH MORETHAN CODING!
Types of BadSoftware Projects
1. Without tests.
Zero Automated Tests.
ZERO!
Lack ofprofessionalism?
Lack ofskills?
Lack ofknowledge?
Lack oftime to test?
It can be allof them.
What aboutsoftware quality?
Relax, they testall features withmanual testing.
2. With WronglyDesigned Tests..
Testing isHARD.
Testing pitfalls:coupling.
ImplementationBoundaryTestingBoundary
ImplementationBoundaryTestingBoundary✅✅✅✅✅ ✅✅✅❌❌
Uncertaintyand Doubt.
ImplementationBoundaryTestingBoundary✅✅✅✅✅❌❌❌❌❌
Testing pitfalls:performance.
Takingtoo much time?— that’s a no run.
Types ofTesting
1. Testing after theimplementation.
2. Testing duringthe implementation.
3. Testing thatreproduce bugs.
It’s our job tobuild a testingculture!
But how?
5 rules.
1. Every changemust have tests.
50100150200Development Unit Tests Functional Tests System Tests ProductionThe cost of bugs
Bugs in productionare embarrassingand costly.
2. Write morethan unit tests.
Mutationtesting!
def add(x,y)x + yenddef add(x,y)x - yendSource Code Mutation
Property-basedtesting!
http://blog.jessitron.com/2013/04/property-based-testing-what-is-it.html
Contracttesting!
Model-basedtesting!
Try formalmethods!https://www.infoq.com/presentations/aws-testing-tla
3. Bug fixingmust have tests.
Don’t repeat thesame bug hunting— write a test!
4. Testing codemust be reviewed.
A well-designed testsuite is much easier toread, understand andevolve.
Testing code isproduction code!
5. Test suitesmust be consistent.
L12. assertEquals(input, expectation);L35. assertEquals(expectation, input);L43. assertThat(input).isEqualTo( expectation);Assertions
L12. createEntityL35. create_withValidPayload_successL43. create_withValidPayload_shouldPersistEntityTest Methods
We must sharethe same values,practices, and tools.
Enforce them through codereviews, static analysis, andstyle checking tools.
Wrapping up.
“People who are successful atautomating tasks tend to workthis way in every aspect of theirjobs. It is just how they work; itis part of their culture.”
Manual workis a bug.acmqueue | january-february 2018
ALWAYS BEAUTOMATING!
GO AND FIX YOURBROKEN CULTURE!