Тёмный

What is TDD? What is Test Driven Development? 

Development That Pays
Подписаться 74 тыс.
Просмотров 43 тыс.
50% 1

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.developmen...
= = = = = = = = = = = =
Grab your FREE Cheat Sheet: www.developmen...
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...

Опубликовано:

 

22 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 18   
@Wineblood
@Wineblood 4 года назад
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.
@Developmentthatpays
@Developmentthatpays 7 лет назад
Just put the finishing touches on the next video. Get ready to dive into Behaviour Driven Development: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-VS6EEUVZGLE.html
@aureatewarrior
@aureatewarrior 5 лет назад
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 👍
@thenylon1003
@thenylon1003 6 лет назад
Thanks alot! It was very informative and fun to watch.
@Developmentthatpays
@Developmentthatpays 6 лет назад
Thank you. Glad you liked it!
@islombekmamatqulov7821
@islombekmamatqulov7821 2 года назад
Bravo !!!, short, clear and interesting :), I appreciate it
@Developmentthatpays
@Developmentthatpays Год назад
Glad you liked it!
@DodaGarcia
@DodaGarcia 3 года назад
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.
@MikeJonesTechno
@MikeJonesTechno 8 лет назад
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 8 лет назад
I'll add them to the list!
@learnuiarchitecture
@learnuiarchitecture 6 лет назад
Good shout!
@learnuiarchitecture
@learnuiarchitecture 6 лет назад
Great videos Gary!
@Developmentthatpays
@Developmentthatpays 6 лет назад
Thank you!
@strawberrycm5073
@strawberrycm5073 3 года назад
Can TDD be conducted manually rather than writing code?
@jasondads9509
@jasondads9509 2 года назад
no.
@pablokintopp2
@pablokintopp2 6 лет назад
Awesome video bro!
@Developmentthatpays
@Developmentthatpays 6 лет назад
+pablo.M.K - Thank you!
Далее
Sh!t Developers Say: "We Need More Tests!"
3:52
Просмотров 8 тыс.
Scrum to Scrumban in 6 Steps + FREE Cheat Sheet
17:05
Просмотров 134 тыс.
People Cling To Trees As Typhoon Slams Into Shanghai
00:34
TDD Is The Best Design Technique
19:26
Просмотров 50 тыс.
Time to stop the madness. Time to stop estimating.
13:18
Test Driven Development vs Behavior Driven Development
18:42
Start Your TDD Journey with C# in 15 MINUTES
14:55
Просмотров 21 тыс.
Don't Mock 3rd Party Code
19:56
Просмотров 39 тыс.
When Test Driven Development Goes Wrong
21:11
Просмотров 73 тыс.
TDD: The Bad Parts - Matt Parker
30:17
Просмотров 54 тыс.
Are You Chicago Or London When It Comes To TDD?
18:58