testing strategies for legacy code

14
Testing strategies for legacy code Alex Soto @alexsotob

Upload: alex-soto

Post on 22-Jan-2018

253 views

Category:

Technology


1 download

TRANSCRIPT

Testing strategies for legacy code

Alex Soto @alexsotob

Alex Soto

Red Hat Engineer Open Source Advocate

www.lordofthejars.com @alexsotob

sdfsd

What is Legacy Code?

It is myth?* Code written by another team* Hasn’t touch for many years* Your are afraid to touch* Not have automated tests

Old Code Needs To Be Maintained

New BugsNew HW OSEnvironment (3rd Party)No Tests

Apply Test First Strategies?

New Features TDDAutomated and Reasonable FastDebuggingOptimazing

How To Start?

Write Any Test (Quick and Easy)Broad Better than NarrowLess tests is better than No TestsIf Existing Flaky Tests (Study and Remove or Mock)

Characterization Tests

Really complicated algorithmCreate a test with wrong values, run it, fails and then we fix it

Tests By Division

Write test for each separated task/flowFront-End you are in trouble try to reduce to API levelFocus on Main Path, avoid edge cases

Code Coverage

Check what you are missingYou are never gonna have 100%

Test Or Debug

When a user found an issue:* Test means you understand the bug* Debug useful for understanding the code

Refactor Legacy Code?

Not Testing in MindNo TestsSo be cautious

Sink In