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

TDD for Rails devs. The long story.

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest. →

TDD for Rails devs. The long story.

Avatar for Volodya Sveredyuk

Volodya Sveredyuk

July 30, 2019

More Decks by Volodya Sveredyuk

Other Decks in Programming

Transcript

  1. Test-driven development (TDD) is a software development process that relies

    on the - repetition of a very short development cycle: • Requirements are turned into very specific test cases • Then the software is improved to pass the new tests, only
  2. 1. Add a test 2. Write a code 3. Run

    tests 4. Refactor code 5. Repeat 3-4 WTF is TDD ?
  3. 1. Test it's also a code 2. Costs time (money)

    3. Slow down delivery 4. Hard. Need to know how to 5. Painful hotfixes or workarounds We don't need tests
  4. Cost time No test for 1st time: Write a code

    - 10 min Check - 5 min Deliver With test for 1st time: Write a test - 10 min Write a code - 10 min Deliver VS.
  5. Cost time Write code for N time: Write a code

    - 10 min Check - 5 min Check dependent code - N x 5 min Deliver
  6. HARD • You fight with syntax • You don't know

    API • You don't know how to test • You don't know what to test • You are a lazy ass
  7. 1. Tests are always part of the development 2. Never

    tests should be extracted into separate task or estimation Remember !
  8. HOW 1. Setup ENV 2. Configure ENV 3. Just do

    it! https://github.com/rspec/rspec-rails
  9. WHAT 1. Every single class 2. Every public method 3.

    Every single endpoint 4. Every single workflow 5. Edge cases
  10. BDD

  11. GOOD TESTS SHOULD BE 1. Easy to write 2. Easy

    to read 3. Reliable (coverage >95%) 4. Fast 5. Truly unit, not integration
  12. BAD TESTS CAN BE 1. Mess 2. DB data sets

    3. Random fails 4. Slow 5. Coupled