SlideShare a Scribd company logo
What NOT to test in your
       project
What NOT to test in your project
?
What NOT to test in your project
1describe “test” do
2 it “should do nothing” do
3    fail
4 end
5 end
What NOT to test in your project
1describe “test” do
2 it “should do nothing” do
3    fail
4 end
5 end
1describe “test” do
2 it “should do nothing” do
3    true
4 end
5 end
What NOT to test in your project
?
1describe “test” do
2 it “should do nothing” do
3    true
4 end
5 end
Do you
DELETE
your tests?
@davidhussman
I think that tests that never fail should
be deleted. If a test doesn’t
communicate something meaningful
about the desing, what is it’s value?
@dhh
I find over-testing to be most
common among those 1st adopting
TDD. So excited about the idea that
they go completely overboard.
Don’t use Cucumber
unless you live in the magic kingdom
of non-coders-writing-tests
(and send me some fairy dust if you are!)
@mfeathers
Ultimately, tests are a feedback
mechanism, and we should make
active decisions about what
feedback we need and when.
What NOT to test in your project
What NOT to test in your project
@unclebobmartin
1 of Kent’s older wise sayings was:
“Test everything that could possibly
break.” I think that’s a pretty good
recipe.
What NOT to test in your project
@metayoda
I would rather have 10% coverage
with 100% quality tests, than 100%
coverage with lousy tests.
What NOT to test in your project
@joshuakerievsky
Test first/after misses the point that
TDD is more about emergent design
than it is about testing. Do you
practice emergent design?
@kentbeck
If I don’t typically make a mistake(...),
I don’t test for it.

Wish there were more examples of
“what not to test”.
What NOT to test in your project
60@Test
61public void setPrice() {
62 Item item = new
63    BasicItem(0.0, true);
64
65 assertEquals(0.0,
66         item.getPrice());
67
68 //set new price
69 item.setPrice(1.0);
70 assertEquals(1.0,
71         item.getPrice());
72}
74@Test
75public void isImported_true(){
76 Item item = new
77     BasicItem(0.0, true);
78
79   assertTrue(item.isImported());
80}
74@Test
75public void isImported_false(){
76 Item item = new
77     BasicItem(0.0, false);
78
79   assertFalse(item.isImported());
80}
28public Double getPrice(){
25 return price;
26}
27
28public boolean isImported(){
29  return imported;
30}
2 def create_name(fname,
3                 lname)
4   raise “fname must be
5         a String”
6    unless fname.kind_of?
7    String
8   raise “lname must be
9         a String”
10   unless lname.kind_of?
11   String
11 end
1 require ‘spec_helper‘
2 describe Candidate do
3   context ‘associations‘ do
4      it { should have_many(:proposals) }
5    end
6
7   context ‘validations‘ do
8      it { should validate_presence_of :name }
9
10     it { should ensure_lenght_of(:phone).
11                   is_at_least(7).
12                   is_at_most(14)
13      }
14
15     it { should_not
16             allow_value(‘blah‘).for(:site) }
17
18     it { should
19             allow_value(‘http://www.blah.com‘)
20               .for(:site) }
21 end
22end
1 require ‘valid_url‘
2 class Candidate < ActiveRecord::Base
3   has_many :proposals
4
5   validates :name, presence: true
6
7   validates :phone, :length =>
8               {:in => 8..14},
9               :allow_blank
10
11 validates :site, :url => true,
12                 :allow_nil => true
13
14end
1 require ‘spec_helper‘
2 describe Candidates do
3
4 let(:candidate) {double ‘candidate‘}
5
6 before :each do
7   Candidate
8     .should_receive(:find)
9       .with(1).and_return(candidate)
10 end
11
12 it ‘should find the candidate‘ do
13   c = Candidate.find(1)
14   c.should eql candidate
15 end
16end
1Feature: Create proposal
2 As a candidate
3 I want to post my proposals
4 So that voters can evaluate them
5
6 Scenario:
7    Given I am logged in
8    And I am posting a proposal
9    When
10    I fill all fields of the proposal
11   Then
12    I should see a success message
1Scenario: Client sees tooltip for plan
2 Given
3    I select the ‘light‘ plan
4 When
5    I mouse over ‘tooltip‘
6 Then
7    I should see ‘tooltip‘ content
8 And
9    I mouse out ‘tooltip‘
10 Then
11   I should not see ‘tooltip‘ content
1require ‘spec_helper‘
2describe ShoppingCart do
3
4 let(:user) {double ‘user‘}
5 let(:product) {double ‘product‘}
6
7 before :each do
8   Authenticator.should_receive(:auth)
9       .and_return(true)
10 end
11
12 it ‘should addProduct & getTotal‘ do
13    Authenticator.auth(user)
14    cart = ShoppingCart.new
15    cart.add_product(product)
16    cart.get_total
17 end
18end
100% COVERED CODE.

                   LINE
  OF CODE YOU COVER
PIXEL NAZI
50@Test
51public void changeMarks() {
52 bot.leftClickAt(view,
53                  800, 508);
54 addMarkAt(‘drama’, 1);
55
56 bot.leftClickAt(view,
57                  900, 508);
58 addMarkAt(‘act’, 3);
59
60 bot.verifyTooltipAt(30, 190);
61}
1 require ‘spec_helper‘
2 describe AddressController do
3
4   it ‘should calculate shipping‘ do
5    get :shipping, :zipcode => ‘90210‘
6    assigns(:shipping).should == ‘8.2‘
7   end
8
9 end
What NOT to test in your project
fixtures
considered
harmful?
<- costumer
                   facing




           VS
  back
office ->
JAVASCRIPT?
module('MultiSelectQuizTests',{
    setup: function() {
        var container =
           document.getElementById("qunit-fixture");
        var question = "Which foods are Mexican?";
        var answers = [
         { 'answerText': 'Tacos', 'value': true },
         { 'answerText': 'Sushi', 'value': false }
        ];

           this.myQuiz = new MultiSelectQuiz
                     ( container, question, answers );
      },
});

test( "One correct", function() {
    checkRadio(0, true);
    checkRadio(1, true);
    deepEqual(this.myQuiz.grade(), 1, "just 1");
});
Being good
at stupid
doesn’t
count.
WHY DO
WE TEST?
Murphy’s law
P
A
I
N
What NOT to test in your project
FLOW
Speed   Robustness
What NOT to test in your project
How much
QUALITY is
ENOUGH?
Bugs/1KLOC
  5
                    0,004
  4


  3


  1


  0

      Indústria   Nasa
Cost($/LOC)
                   850
 900


 675


 450


 225
       5
   0

       Indústria     Nasa
@marick
I test the high risk code thoroughly.
I use up most of the remaining time
testing the medium risk code.
I don’t intentionally test the low risk
code.
@martinfowler
you’re doing enough testing if the
following is true:
 ■You rarely get bugs that escape
  into production
 ■You are rarely hesitant to change
  some code for fear it will cause
  production bugs
@jamesshore
Skill and discipline give us fluency.
Then fluency gives us ease and joy.
What NOT to test in your project
LESSONS
LEARNED
baby steps:
grow up,
the real
world is not
a dojo
D
R
Y
WET
Test
journeys
Too much
sleep()
non-
deterministic
or flaky test
suite
What NOT to test in your project
@google
If they fail we simply run flaky tests
3x (and keep statistics). Developer
time is much more valuable than
server time.
@javosantillan
I see companies that don’t test real
integration until the very end. And
also don’t test performance, leaving it
to the end, or worse, not testing at
all.
external
dependencies:
SCALABILITY
              SECURITY

 NON-FUNCTIONAL
 REQUIREMENTS
PERFORMANCE
              RELIABILITY
What NOT to test in your project
technique
    vs
   tool
feedback
   vs
  noise
Evolutionary
     design
       vs
 Guarantee of
working software
deciding what
NOT to test is
as IMPORTANT
as writing tests
bring the
pain
forward
JOIN
              the
              RE-
              VO-
              LU-
              TI-
JAVASCRIPT    ON
agradecimentos:
@camiloribeiro, @lucabastos, @neal4rd,
@tottinge, @brownie490, @hugocorbucci,
@dtsato, @p_balduino, @mauricioaniche,
 @cecifernandes, @marick, @mfeathers,
  @dhh, @martinfowler, @jamesshore,
    @joshuakeriesvisky, @kentbeck,
  @unclebobmartin, @klauswuestefeld,
    @guilhermesilveira, @metayoda,
      @javosantillan, @rafelmolesin,
       @davidhussman, @mvaltas

More Related Content

PDF
Como NÃO testar o seu projeto de Software. DevDay 2014
PDF
Test Smart, not hard
PDF
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
PPTX
Writing Test Cases with PHPUnit
PDF
Unit testing PHP apps with PHPUnit
PPTX
TDD in Powershell
PDF
Introduction to Unit Testing with PHPUnit
KEY
PHPUnit testing to Zend_Test
Como NÃO testar o seu projeto de Software. DevDay 2014
Test Smart, not hard
FAQ - why does my code throw a null pointer exception - common reason #1 Rede...
Writing Test Cases with PHPUnit
Unit testing PHP apps with PHPUnit
TDD in Powershell
Introduction to Unit Testing with PHPUnit
PHPUnit testing to Zend_Test

What's hot (7)

PPT
Test Driven Development with PHPUnit
PPTX
Unit Testing Presentation
PPTX
PHPUnit: from zero to hero
PDF
Unit testing with PHPUnit - there's life outside of TDD
KEY
Workshop quality assurance for php projects tek12
PDF
TDD CrashCourse Part3: TDD Techniques
PDF
Parametrized testing, v2
Test Driven Development with PHPUnit
Unit Testing Presentation
PHPUnit: from zero to hero
Unit testing with PHPUnit - there's life outside of TDD
Workshop quality assurance for php projects tek12
TDD CrashCourse Part3: TDD Techniques
Parametrized testing, v2
Ad

Similar to What NOT to test in your project (20)

PDF
Software testing lab manual
PDF
Getting Started With Testing
PDF
Mutation Testing with PIT
PDF
When Tdd Goes Awry (IAD 2013)
PDF
des mutants dans le code.pdf
PPTX
Building unit tests correctly
PDF
We Are All Testers Now: The Testing Pyramid and Front-End Development
PPTX
Building unit tests correctly with visual studio 2013
PDF
The limits of unit testing by Craig Stuntz
PDF
The Limits of Unit Testing by Craig Stuntz
PDF
Tests unitaires mock_kesako_20130516
PDF
Developer Test - Things to Know
PDF
How to apply AI to Testing
PDF
Test driven development
PPT
Test Infected Presentation
PDF
Surviving javascript.pptx
PDF
Mutation testing with PIT
PDF
Антипаттерны модульного тестирования
PDF
Apex Unit Testing in the Real World
PDF
淺談高效撰寫單元測試
Software testing lab manual
Getting Started With Testing
Mutation Testing with PIT
When Tdd Goes Awry (IAD 2013)
des mutants dans le code.pdf
Building unit tests correctly
We Are All Testers Now: The Testing Pyramid and Front-End Development
Building unit tests correctly with visual studio 2013
The limits of unit testing by Craig Stuntz
The Limits of Unit Testing by Craig Stuntz
Tests unitaires mock_kesako_20130516
Developer Test - Things to Know
How to apply AI to Testing
Test driven development
Test Infected Presentation
Surviving javascript.pptx
Mutation testing with PIT
Антипаттерны модульного тестирования
Apex Unit Testing in the Real World
淺談高效撰寫單元測試
Ad

More from alexandre freire (16)

PDF
Making People Awesome @Nubank TDC Floripa 2019
PDF
Technical Product Management at Nubank
PDF
Making People Awesome TDC POA 2018 - Alexandre Freire
PDF
Modern Agile and the Future of SW Development GUMARS 2018
PDF
Deploy Contínuo de Software Legado: Loucura ou Genialidade?
PDF
Como influenciar sua equipe para ser excelente com medo, culpa, vergonha, pun...
PDF
Otimizando sua Máquina Cultural na busca pela excelência QCon SP 2015
PDF
Agile #FAIL QCon 2013
PDF
Tech Safety - um caminho inesperado à excelência
PDF
Como não testar seu projeto de software
PDF
Divida tecnica
PDF
Ágil x Lean Startup no Caipira Ágil
PDF
Progamacao para não programadores
PDF
surge con 2011 lightning talk - closed loop server lifecycle
PPTX
Dívida tecnica: precisando de crédito? Quão fundo entrar e como evitar que o ...
PPTX
COWBLAM! - a sua metodologia é a melhor. Agile Brasil 2011
Making People Awesome @Nubank TDC Floripa 2019
Technical Product Management at Nubank
Making People Awesome TDC POA 2018 - Alexandre Freire
Modern Agile and the Future of SW Development GUMARS 2018
Deploy Contínuo de Software Legado: Loucura ou Genialidade?
Como influenciar sua equipe para ser excelente com medo, culpa, vergonha, pun...
Otimizando sua Máquina Cultural na busca pela excelência QCon SP 2015
Agile #FAIL QCon 2013
Tech Safety - um caminho inesperado à excelência
Como não testar seu projeto de software
Divida tecnica
Ágil x Lean Startup no Caipira Ágil
Progamacao para não programadores
surge con 2011 lightning talk - closed loop server lifecycle
Dívida tecnica: precisando de crédito? Quão fundo entrar e como evitar que o ...
COWBLAM! - a sua metodologia é a melhor. Agile Brasil 2011

What NOT to test in your project