Upgrade to Pro — share decks privately, control downloads, hide ads and more …

TDD - Test Driven Development

TDD - Test Driven Development

Aslanoba Tech Talks'da Uğur Özyılmazel tarafından yapılan TDD metodolojisi sunumu.

Aslanoba Labs

April 29, 2015
Tweet

More Decks by Aslanoba Labs

Other Decks in Programming

Transcript

  1. TDD

  2. FAYDALARI • BUG FREE geliştirme • Hızlı geliştirme • Dökümantasyon

    yazma zahmetinden kurtarıyor • Sürdürülebilir kod yazma • Uçtan uca uygulamayı görmek • Deployment otomasyonunda kolaylık • Test Coverage
  3. DEZAVANTAJLARI • Legacy code'a entegre etmek sorun olabilir • Test'lerin

    maintenance işi ve test süresi • "Quick Edit" mini değişimler için zor • False Positives • Edge Case'leri mutlaka tamamlamak gerek
  4. !

  5. require 'test/unit' class TestPalindrome < Test::Unit::TestCase def test_palindrome palindromes =

    ["anastas mum satsana", "kuk"] not_palindromes = ["hello", "mello"] palindromes.each{|str| assert palindrome?(str)} not_palindromes.each{|str| assert !palindrome?(str)} end end def palindrome?(string) string.reverse == string end
  6. Loaded suite untitled Started . Finished in 0.001015 seconds. 1

    tests, 4 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 985.22 tests/s, 3940.89 assertions/s
  7. it "allows setting these responses" do fake_person = double("Person") allow(fake_person).to

    receive_messages(:full_name => "Uğur Özyılmazel") expect(fake_person.full_name).to eq("Uğur Özyılmazel") end it "stubs desired year on a real Time object" do time = Time.new.now allow(time).to receive(:year).and_return(1972) expect(time.year).to eq(1975) end