Reversed TTeessttss PPyyrraammiidd –– DDeeaalliinngg WWiitthh 
LLeeggaaccyy CCooddee 
Wiktor Żołnowski 
@streser 
http://www.agileszkolenia.pl 
http://codesprinters.com 
@pragmaticcoders 
http://pragmaticcoders.com
Can you imagine perfect software?
Tests pyramid 
End to End Tests 
Functional/Integration Tests 
Unit Tests
It would be perfect to work with perfect 
software every day...
But!
Reality...
Is...
Different!
Legacy Code
How did we get to this point?
It's all because of the money...
Technical Debt
Sometimes Technical Debt could be 
considered as something good...
Unfortunately temptation of easy 
making money is huge...
People lives in illusion of continuous, 
fast and low cost development...
Forgetting about the Quality...
Success in Software Development is something which is not 
continuous...
Success is state that you can achieve but also lose very fast 
if you can't respond to changes fast enough...
So, is it possible to deal with legacy code?
Reversed Tests Pyramid 
End-to-End Tests 
Functional/Integration Tests 
Unit Tests
- What?!
You can't do unit testing when there are 
no units in your software...
You can't do integration tests when 
there is nothing to integrate...
You need to refactor your code so it 
would be testable...
How to refactor without tests?!
Now refactor... 
High level tests gives you courage to refactor your code... 
●
But.. There are few reasons why you shouldn't 
reverse tests pyramid 
End-To-End tests are too long...
End-to-end tests are difficult to maintain... 
If we need end-to-end tests we are probably doing something 
wrong with our architecture...
So it's all about reversing back our 
tests pyramid.
Step by step we are introducing new 
architecture...
Remember that creating reversed tests 
pyramid and reversing it back will take 
some time...
But you need to do this if you want to 
pay your technical debt back!
Few final thoughts... 
Keep your technical debt as low as possible and try to 
pay it back every time you can. For example use your 
slack time for that!
Remember - WHY we are doing this?
“Leave the world better then you found it”
Beware of refactoring just for refactoring! 
Few final thoughts...
Few final thoughts... 
● Beware of refactoring just for refactoring! 
● Resist temptation to re-write from scratch – history is against you, 
such projects usually fail. 
● Remember to always remove your (duplicated) tests! 
● Software quality in many cases could be understood as ability to 
introduce changes into software! 
● Keep your technical debt as low as possible and try to pay it back 
every time you can. For example use your slack time for that! 
Resist temptation to re-write from scratch – history is 
against you, such projects usually fail.
Few final thoughts... 
● Beware of refactoring just for refactoring! 
● Resist temptation to re-write from scratch – history is against you, 
such projects usually fail. 
● Remember to always remove your (duplicated) tests! 
Remember to always remove your (duplicated) tests! 
● Software quality in many cases could be understood as ability to 
introduce changes into software! 
● Keep your technical debt as low as possible and try to pay it back 
every time you can. For example use your slack time for that!
False positive or false negative safety 
net is even worst than lack of safety 
net...
● Software quality in many cases could be understood as 
ability to introduce changes into software!
Wiktor Żołnowski 
agileszkolenia.pl 
Questions? 
@streser 
http://pragmaticcoders.com 
http://codesprinters.com

Reversed Tests Pyramid - Agile Prague 2014

  • 1.
    Reversed TTeessttss PPyyrraammiidd–– DDeeaalliinngg WWiitthh LLeeggaaccyy CCooddee Wiktor Żołnowski @streser http://www.agileszkolenia.pl http://codesprinters.com @pragmaticcoders http://pragmaticcoders.com
  • 2.
    Can you imagineperfect software?
  • 4.
    Tests pyramid Endto End Tests Functional/Integration Tests Unit Tests
  • 5.
    It would beperfect to work with perfect software every day...
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
    How did weget to this point?
  • 12.
    It's all becauseof the money...
  • 13.
  • 14.
    Sometimes Technical Debtcould be considered as something good...
  • 15.
    Unfortunately temptation ofeasy making money is huge...
  • 16.
    People lives inillusion of continuous, fast and low cost development...
  • 17.
  • 18.
    Success in SoftwareDevelopment is something which is not continuous...
  • 19.
    Success is statethat you can achieve but also lose very fast if you can't respond to changes fast enough...
  • 20.
    So, is itpossible to deal with legacy code?
  • 21.
    Reversed Tests Pyramid End-to-End Tests Functional/Integration Tests Unit Tests
  • 22.
  • 23.
    You can't dounit testing when there are no units in your software...
  • 24.
    You can't dointegration tests when there is nothing to integrate...
  • 25.
    You need torefactor your code so it would be testable...
  • 26.
    How to refactorwithout tests?!
  • 27.
    Now refactor... Highlevel tests gives you courage to refactor your code... ●
  • 28.
    But.. There arefew reasons why you shouldn't reverse tests pyramid End-To-End tests are too long...
  • 29.
    End-to-end tests aredifficult to maintain... If we need end-to-end tests we are probably doing something wrong with our architecture...
  • 30.
    So it's allabout reversing back our tests pyramid.
  • 31.
    Step by stepwe are introducing new architecture...
  • 32.
    Remember that creatingreversed tests pyramid and reversing it back will take some time...
  • 33.
    But you needto do this if you want to pay your technical debt back!
  • 34.
    Few final thoughts... Keep your technical debt as low as possible and try to pay it back every time you can. For example use your slack time for that!
  • 35.
    Remember - WHYwe are doing this?
  • 36.
    “Leave the worldbetter then you found it”
  • 37.
    Beware of refactoringjust for refactoring! Few final thoughts...
  • 38.
    Few final thoughts... ● Beware of refactoring just for refactoring! ● Resist temptation to re-write from scratch – history is against you, such projects usually fail. ● Remember to always remove your (duplicated) tests! ● Software quality in many cases could be understood as ability to introduce changes into software! ● Keep your technical debt as low as possible and try to pay it back every time you can. For example use your slack time for that! Resist temptation to re-write from scratch – history is against you, such projects usually fail.
  • 39.
    Few final thoughts... ● Beware of refactoring just for refactoring! ● Resist temptation to re-write from scratch – history is against you, such projects usually fail. ● Remember to always remove your (duplicated) tests! Remember to always remove your (duplicated) tests! ● Software quality in many cases could be understood as ability to introduce changes into software! ● Keep your technical debt as low as possible and try to pay it back every time you can. For example use your slack time for that!
  • 40.
    False positive orfalse negative safety net is even worst than lack of safety net...
  • 41.
    ● Software qualityin many cases could be understood as ability to introduce changes into software!
  • 42.
    Wiktor Żołnowski agileszkolenia.pl Questions? @streser http://pragmaticcoders.com http://codesprinters.com