What NOT to test in your project
Upcoming SlideShare
Loading in...5
×
 

What NOT to test in your project

on

  • 995 views

In this talk we discuss automated testing and give examples of tests we've seen (or written ourselves) that we don't believe add value to your test suite. These slides accompany a live talk so you ...

In this talk we discuss automated testing and give examples of tests we've seen (or written ourselves) that we don't believe add value to your test suite. These slides accompany a live talk so you might not get that much from them alone...

Statistics

Views

Total Views
995
Views on SlideShare
984
Embed Views
11

Actions

Likes
6
Downloads
19
Comments
1

1 Embed 11

https://twitter.com 11

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    What NOT to test in your project What NOT to test in your project Presentation Transcript

    • What NOT to test in your project
    • ?
    • 1describe “test” do2 it “should do nothing” do3 fail4 end5 end
    • 1describe “test” do2 it “should do nothing” do3 fail4 end5 end
    • 1describe “test” do2 it “should do nothing” do3 true4 end5 end
    • ?1describe “test” do2 it “should do nothing” do3 true4 end5 end
    • Do youDELETEyour tests?
    • @davidhussmanI think that tests that never fail shouldbe deleted. If a test doesn’tcommunicate something meaningfulabout the desing, what is it’s value?
    • @dhhI find over-testing to be mostcommon among those 1st adoptingTDD. So excited about the idea thatthey go completely overboard.
    • Don’t use Cucumberunless you live in the magic kingdomof non-coders-writing-tests(and send me some fairy dust if you are!)
    • @mfeathersUltimately, tests are a feedbackmechanism, and we should makeactive decisions about whatfeedback we need and when.
    • @unclebobmartin1 of Kent’s older wise sayings was:“Test everything that could possiblybreak.” I think that’s a pretty goodrecipe.
    • @metayodaI would rather have 10% coveragewith 100% quality tests, than 100%coverage with lousy tests.
    • @joshuakerievskyTest first/after misses the point thatTDD is more about emergent designthan it is about testing. Do youpractice emergent design?
    • @kentbeckIf I don’t typically make a mistake(...),I don’t test for it.Wish there were more examples of“what not to test”.
    • 60@Test61public void setPrice() {62 Item item = new63 BasicItem(0.0, true);6465 assertEquals(0.0,66 item.getPrice());6768 //set new price69 item.setPrice(1.0);70 assertEquals(1.0,71 item.getPrice());72}
    • 74@Test75public void isImported_true(){76 Item item = new77 BasicItem(0.0, true);7879 assertTrue(item.isImported());80}
    • 74@Test75public void isImported_false(){76 Item item = new77 BasicItem(0.0, false);7879 assertFalse(item.isImported());80}
    • 28public Double getPrice(){25 return price;26}2728public boolean isImported(){29 return imported;30}
    • 2 def create_name(fname,3 lname)4 raise “fname must be5 a String”6 unless fname.kind_of?7 String8 raise “lname must be9 a String”10 unless lname.kind_of?11 String11 end
    • 1 require ‘spec_helper‘2 describe Candidate do3 context ‘associations‘ do4 it { should have_many(:proposals) }5 end67 context ‘validations‘ do8 it { should validate_presence_of :name }910 it { should ensure_lenght_of(:phone).11 is_at_least(7).12 is_at_most(14)13 }1415 it { should_not16 allow_value(‘blah‘).for(:site) }1718 it { should19 allow_value(‘http://www.blah.com‘)20 .for(:site) }21 end22end
    • 1 require ‘valid_url‘2 class Candidate < ActiveRecord::Base3 has_many :proposals45 validates :name, presence: true67 validates :phone, :length =>8 {:in => 8..14},9 :allow_blank1011 validates :site, :url => true,12 :allow_nil => true1314end
    • 1 require ‘spec_helper‘2 describe Candidates do34 let(:candidate) {double ‘candidate‘}56 before :each do7 Candidate8 .should_receive(:find)9 .with(1).and_return(candidate)10 end1112 it ‘should find the candidate‘ do13 c = Candidate.find(1)14 c.should eql candidate15 end16end
    • 1Feature: Create proposal2 As a candidate3 I want to post my proposals4 So that voters can evaluate them56 Scenario:7 Given I am logged in8 And I am posting a proposal9 When10 I fill all fields of the proposal11 Then12 I should see a success message
    • 1Scenario: Client sees tooltip for plan2 Given3 I select the ‘light‘ plan4 When5 I mouse over ‘tooltip‘6 Then7 I should see ‘tooltip‘ content8 And9 I mouse out ‘tooltip‘10 Then11 I should not see ‘tooltip‘ content
    • 1require ‘spec_helper‘2describe ShoppingCart do34 let(:user) {double ‘user‘}5 let(:product) {double ‘product‘}67 before :each do8 Authenticator.should_receive(:auth)9 .and_return(true)10 end1112 it ‘should addProduct & getTotal‘ do13 Authenticator.auth(user)14 cart = ShoppingCart.new15 cart.add_product(product)16 cart.get_total17 end18end
    • 100% COVERED CODE. LINE OF CODE YOU COVER
    • PIXEL NAZI
    • 50@Test51public void changeMarks() {52 bot.leftClickAt(view,53 800, 508);54 addMarkAt(‘drama’, 1);5556 bot.leftClickAt(view,57 900, 508);58 addMarkAt(‘act’, 3);5960 bot.verifyTooltipAt(30, 190);61}
    • 1 require ‘spec_helper‘2 describe AddressController do34 it ‘should calculate shipping‘ do5 get :shipping, :zipcode => ‘90210‘6 assigns(:shipping).should == ‘8.2‘7 end89 end
    • fixturesconsideredharmful?
    • <- costumer facing VS backoffice ->
    • 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 goodat stupiddoesn’tcount.
    • WHY DOWE TEST?
    • Murphy’s law
    • PAIN
    • FLOW
    • Speed Robustness
    • How muchQUALITY isENOUGH?
    • Bugs/1KLOC 5 0,004 4 3 1 0 Indústria Nasa
    • Cost($/LOC) 850 900 675 450 225 5 0 Indústria Nasa
    • @marickI test the high risk code thoroughly.I use up most of the remaining timetesting the medium risk code.I don’t intentionally test the low riskcode.
    • @martinfowleryou’re doing enough testing if thefollowing 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
    • @jamesshoreSkill and discipline give us fluency.Then fluency gives us ease and joy.
    • LESSONSLEARNED
    • baby steps:grow up,the realworld is nota dojo
    • DRY
    • WET
    • Testjourneys
    • Too muchsleep()
    • non-deterministicor flaky testsuite
    • @googleIf they fail we simply run flaky tests3x (and keep statistics). Developertime is much more valuable thanserver time.
    • @javosantillanI see companies that don’t test realintegration until the very end. Andalso don’t test performance, leaving itto the end, or worse, not testing atall.
    • externaldependencies:
    • SCALABILITY SECURITY NON-FUNCTIONAL REQUIREMENTSPERFORMANCE RELIABILITY
    • technique vs tool
    • feedback vs noise
    • Evolutionary design vs Guarantee ofworking software
    • deciding whatNOT to test isas IMPORTANTas writing tests
    • bring thepainforward
    • 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