What is TDD? What is Test Driven Development?

Тәжірибелік нұсқаулар және стиль

In this non-technical intro to TDD, we'll be digging into Unit Tests, test isolation and the mysterious world of mocking
= = = = = = = = = = = =
New for 2024: my best-ever training:
"How Your Agile Teams Can Achieve Predictability and Productivity WITHOUT Burnout"
→ www.developmentthatpays.com/w...
= = = = = = = = = = = =
Grab your FREE Cheat Sheet: www.developmentthatpays.com/c...
Welcome to a stricty non-technical introduction to Test Driven Development - aka TDD. We'll be digging into Unit Tests, test isolation and the myserious world of mocking.
Key take-aways on Unit Tests:
- Writing Unit Tests for existing code can be difficult... or impossible
- A Unit Test is a test of a component in isolation
- In order to test is isolation, any external dependencies must be "mocked"
- An example of something that is frequently "mocked" is a database connection
- Units Tests tend to be very fast to run.
Key take-aways on Test Driven Development:
- It's an iterative process: write a small test... write just enough code to get the test to pass. Rinse and repeat.
- The tests and the code that the tests "cover" are born and grow together. They are intertwined.
Music: 260809 Funky Nurykabe: ccmixter.org/files/jlbrock44/29186
-------------------
60. What is TDD? What is Test Driven Development?
#DevelopmentThatPays
What is Test Driven Development Aka TDD I'm glad you asked! Unit Tests... can be hard --------- First things first. If we're going to talk about Test Driven Development, we first need to talk about the particular type of test that underlies TDD: Unit Tests. I first came across Unit Testing in about 2008. By that point, I'd been developing full time for a few years. I thought I had it down. But I found writing unit tests to be hard. Damn hard. 10x harder than writing code. Depressing. I eventually discovered that it wasn't my fault. Much of the stuff that I thought was impossible to test .... ... really WAS impossible to test. It wasn't me after all! Why were the tests impossible to write I was trying - and failing - to write a test for something that... ... wasn't like a spark plug. Test Isolation ----- Remember in the last episode we talked about testing the gap of the spark plug That's a perfect example of a Unit Test. Another perfect example would be a test of its resistance. With the right equipment, we could even perform a unit test to confirm that it sparks. All of these tests are possible because there's something special about a spark plug It's... TESTABLE! By design, it can be removed from the engine. It's one of the few things in the world that has a (more or less) standardised tool for removing it. My guess is that spark plugs weren't designed specifically to be testable. I think it's probably the case that spark plugs were designed to be replaceable and test-ability came as a very useful side effect. It's been my experience that things rarely evolve naturally to be replaceable/testable. They are replaceable/testable by design. Or not at all. Nowhere is this more true than with software. I can say with a high level of confidence, that if your codebase does not have unit tests, then your codebase consists largely of UNTESTABLE code. Test Driven Development ---------- Which brings us nicely on to Test Driven Development. Test Driven Development, as the name suggests, is a process by which the tests are written BEFORE the code. This doesn't mean writing all of the tests and then writing all of the code. it's more subtle than that. You start by writing just one test. A very small test. Then you write some code. Just enough code to get the test to pass. Then you write another small test. Rinse and repeat. The code and the tests are born and grow together. The test-ability of the code is "built in". Mocking ------- Writing Unit Tests is easier for new code than for existing code. But that's not to say that it's trivial. There is a complication. The key to a unit test is to test the "unit" in isolation. If you saw the previous episode, I performed the following test: I removed the plug cap, unscrewed the spark plug, plugged it back into the plug cap and operated the kick starter. This was a test for spark, but it was NOT a Unit Test. Because it's not a test of the spark plug in isolation. (It's actually a test of a whole host of components working together.) A Unit Test is possible. It just needs some additional equipment. This device takes the place of the battery and a whole array of electrical equipment. The device is assumed to be working, so if there's no spark, we know that it's the spark plug that's at fault. The so
• What is TDD? What is T...
• Software Development T...

Пікірлер: 18

  • @Wineblood
    @Wineblood3 жыл бұрын

    As nicely as TDD is explained here, I have never seen it work and it's always more painful than anything else. I do think BDD is a big step forward.

  • @thenylon1003
    @thenylon10036 жыл бұрын

    Thanks alot! It was very informative and fun to watch.

  • @Developmentthatpays

    @Developmentthatpays

    6 жыл бұрын

    Thank you. Glad you liked it!

  • @aureatewarrior
    @aureatewarrior5 жыл бұрын

    Great video! I'm only half way in and was somewhat confused on what exactly TDD was. Very informative, great visuals, and thank you for the detail in a simplistic way since I myself am new to TDD, and BDD.

  • @Developmentthatpays

    @Developmentthatpays

    5 жыл бұрын

    Glad that it was helpful 👍

  • @islombekmamatqulov7821
    @islombekmamatqulov7821 Жыл бұрын

    Bravo !!!, short, clear and interesting :), I appreciate it

  • @Developmentthatpays

    @Developmentthatpays

    Жыл бұрын

    Glad you liked it!

  • @MikeJonesTechno
    @MikeJonesTechno7 жыл бұрын

    Look forward to the next episode. Please could you do a future video on Dependency Injection? Or how developers can start introducing S.O.L.I.D. principles to legacy code?

  • @Developmentthatpays

    @Developmentthatpays

    7 жыл бұрын

    I'll add them to the list!

  • @learnuiarchitecture

    @learnuiarchitecture

    6 жыл бұрын

    Good shout!

  • @DodaGarcia
    @DodaGarcia3 жыл бұрын

    As most everyone else I took forever to try TDD because it sounded like it took too much time, now I don't feel comfortable if I wrote any code without writing a test first. Writing tests obviously does take time, but it's a fraction of the time spend debugging the code later as it grows. Can't even compare.

  • @Developmentthatpays
    @Developmentthatpays7 жыл бұрын

    Just put the finishing touches on the next video. Get ready to dive into Behaviour Driven Development: kzread.info/dash/bejne/iIdqp6eOhr2tfKg.html

  • @learnuiarchitecture
    @learnuiarchitecture6 жыл бұрын

    Great videos Gary!

  • @Developmentthatpays

    @Developmentthatpays

    6 жыл бұрын

    Thank you!

  • @pablokintopp2
    @pablokintopp26 жыл бұрын

    Awesome video bro!

  • @Developmentthatpays

    @Developmentthatpays

    6 жыл бұрын

    +pablo.M.K - Thank you!

  • @strawberrycm5073
    @strawberrycm50733 жыл бұрын

    Can TDD be conducted manually rather than writing code?

  • @jasondads9509

    @jasondads9509

    2 жыл бұрын

    no.

Келесі