Something You Always Wanted to Know
About Testing*
*But Were Afraid to Ask
Jorge Juan Barroso Carmona
Android Expert
@flipper83 jorge@karumi.com
if the time should come when you have to make
a choice between what is right, and what is
easy!!
What is Testing?
Checking is confirmation, verification, and
validation. By machines.
Testing is exploration, discovery,
investigation, and learning. By humans.
versus
Why Testing?
Martin
Fowler
“ more Functionality
more Quickly ”
“ Bad code affect to
your Costumer ”
“ Trabajar con una base de tests en condiciones es un puto
gustazo!!! ”
@pedro_g_s
What are Unit Tests?
Black-Box before White-Box
creating tests in an environment where they
have some Control over their own
Destiny.
Be careful, sometimes Context is
Everything.
more Information in a test than in code.
Paranoid?
Don’t create your own Problems.
Turn most unit tests into Assertions.
Don’t test Implementation Details.
“ Si tu Unit test tarda más de 1 segundo, cómprate un pony
y no me vendas que eso es un Unit test ”
@Jordi9
Mock or Stub?
Stubs are canned answers to calls.
Mocks are objects pre-programmed with
expectations.
Avoid creating methods only for stubs.
A Big dependency of Robolectric and
PowerMock is a sign of bad code.
Mock dilema: your test only checks that
your mocks works.
What are Integration Tests?
Don’t test all your Layers at the same time
Or at least Be aware you are doing it
Duplicated tests.
Write O(n!) tests.
where “n” it’s the number of collaborators
Don’t test the System or External Libraries.
Sometimes is a Good practice to test all your
layers.
Why you
should use
Continuous
Integration
The best test is the one that is Never executed.
Increase your Time to develop.
Everyone has the latest executable and can see
what’s happening.
“ automated crap is still crap. ”
James O Coplien
How to
decide the
Test
Coverage?
Low level coverage says that the code is badly
tested, but you cannot claim the opposite with just
high level coverage
100% coverage is to test all possible code paths.
Is TDD here?
Tests are Code, we need to maintain them.
Risk-based Testing: prioritize the test over the
risk of failure, the importance and the impact of
failure.
“ I get paid for code that works, not for tests, so my
philosophy is to test as little as possible to reach a given
level of confidence ”
Kent Beck
“ In most businesses, the only tests that have business
value are those that are derived from business
requirements. ”
James O Coplien
How Does
it affect
to my code?
Silver bullets do not exist.
The really important thing is to write
Faster and better code
And please, expose your Dependencies
and write Readable code
your Code is more important than your tests.
“ If you find your testers splitting up functions to support the
testing process, you’re destroying your system architecture
and code comprehension along with it. Test at a coarser
level of granularity. ”
James O Coplien
“ When you are very thirsty, even dirty water will keep you
alive. ”
J. B. Rainsberger
+ James Bach and michael bolton. checking vs testing (2009 -
2013)
+ Workflows of Refactoring. martin fowler. (oop 2014)
+ Why Most Unit Testing is Waste. James O Coplien (2013)
+ 467 tests, 0 failures, 0 confidence. Katrina Owen (Railsberry
2013)
+ Mocks Aren't Stubs. martin fowler (2007)
+ Integrated Tests Are A Scam. J.B. Rainsberger (2013)
+ Exploratory and Risk Based Testing. Bach, J. Kaner, C. (2004)
+ Decomposing into modules. D.L. Parnas (1972)
+ The Art of Unit Testing. Roy Osherove
+ Test Driven Development: By Example. Kent Beck
+ UnitTest. Martin fowler 2014
References
Q&A?@flipper83 jorge@karumi.com

All you need know about testing

  • 1.
    Something You AlwaysWanted to Know About Testing* *But Were Afraid to Ask Jorge Juan Barroso Carmona Android Expert @flipper83 jorge@karumi.com
  • 2.
    if the timeshould come when you have to make a choice between what is right, and what is easy!!
  • 3.
  • 4.
    Checking is confirmation,verification, and validation. By machines. Testing is exploration, discovery, investigation, and learning. By humans. versus
  • 5.
  • 6.
    “ more Functionality moreQuickly ” “ Bad code affect to your Costumer ”
  • 7.
    “ Trabajar conuna base de tests en condiciones es un puto gustazo!!! ” @pedro_g_s
  • 8.
  • 9.
  • 10.
    creating tests inan environment where they have some Control over their own Destiny. Be careful, sometimes Context is Everything.
  • 11.
    more Information ina test than in code. Paranoid?
  • 12.
    Don’t create yourown Problems. Turn most unit tests into Assertions. Don’t test Implementation Details.
  • 13.
    “ Si tuUnit test tarda más de 1 segundo, cómprate un pony y no me vendas que eso es un Unit test ” @Jordi9
  • 14.
  • 15.
    Stubs are cannedanswers to calls. Mocks are objects pre-programmed with expectations.
  • 16.
    Avoid creating methodsonly for stubs.
  • 17.
    A Big dependencyof Robolectric and PowerMock is a sign of bad code.
  • 18.
    Mock dilema: yourtest only checks that your mocks works.
  • 19.
  • 20.
    Don’t test allyour Layers at the same time Or at least Be aware you are doing it
  • 21.
    Duplicated tests. Write O(n!)tests. where “n” it’s the number of collaborators
  • 22.
    Don’t test theSystem or External Libraries. Sometimes is a Good practice to test all your layers.
  • 23.
  • 24.
    The best testis the one that is Never executed. Increase your Time to develop. Everyone has the latest executable and can see what’s happening.
  • 25.
    “ automated crapis still crap. ” James O Coplien
  • 26.
  • 27.
    Low level coveragesays that the code is badly tested, but you cannot claim the opposite with just high level coverage
  • 28.
    100% coverage isto test all possible code paths. Is TDD here? Tests are Code, we need to maintain them.
  • 29.
    Risk-based Testing: prioritizethe test over the risk of failure, the importance and the impact of failure.
  • 30.
    “ I getpaid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence ” Kent Beck “ In most businesses, the only tests that have business value are those that are derived from business requirements. ” James O Coplien
  • 31.
  • 32.
  • 33.
    The really importantthing is to write Faster and better code
  • 34.
    And please, exposeyour Dependencies and write Readable code
  • 35.
    your Code ismore important than your tests.
  • 36.
    “ If youfind your testers splitting up functions to support the testing process, you’re destroying your system architecture and code comprehension along with it. Test at a coarser level of granularity. ” James O Coplien “ When you are very thirsty, even dirty water will keep you alive. ” J. B. Rainsberger
  • 37.
    + James Bachand michael bolton. checking vs testing (2009 - 2013) + Workflows of Refactoring. martin fowler. (oop 2014) + Why Most Unit Testing is Waste. James O Coplien (2013) + 467 tests, 0 failures, 0 confidence. Katrina Owen (Railsberry 2013) + Mocks Aren't Stubs. martin fowler (2007) + Integrated Tests Are A Scam. J.B. Rainsberger (2013) + Exploratory and Risk Based Testing. Bach, J. Kaner, C. (2004) + Decomposing into modules. D.L. Parnas (1972) + The Art of Unit Testing. Roy Osherove + Test Driven Development: By Example. Kent Beck + UnitTest. Martin fowler 2014 References
  • 38.