How to make code more testable, by factoring out and abstracting side effects

Опубликовано: 19 Октябрь 2021
на канале: Studying With Alex
52,427
2.8k

As a software engineer, sometimes the code you're trying to test accesses the filesystem, databases, other services, or the internet. But including them as part of the test makes tests slower, more brittle, and more expensive. I'll show you a best-practices way to factor out and abstract those pieces of your code so that it becomes easier to test, using our friends factoring, abstraction, and dependency injection.

Github repo with the code: https://github.com/aquach/studying-wi...

Blog post about how to decide what tests to write: https://blog.alexqua.ch/posts/how-to-...

Credits:

Raysonho @ Open Grid Scheduler / Grid Engine, CC0, via Wikimedia Commons
Rillke, CC BY-SA 3.0, via Wikimedia Commons
Amin, CC BY-SA 4.0, via Wikimedia Commons

00:00 Writing Some Code
02:46 Why Tests That Don't Touch The Filesystem Are Great
03:10 How To Refactor The Test To Not Touch The Filesystem
06:06 Intro To Abstraction
07:25 Abstraction In Everyday Life
07:46 Solving Our Problem With Abstraction
08:10 Coding The Abstraction Layer
10:26 Writing A Test Against The Abstraction Layer
12:11 Abstraction Recap
12:52 Testing Rules Of Thumb Recap


Смотрите видео How to make code more testable, by factoring out and abstracting side effects онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Studying With Alex 19 Октябрь 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 52,427 раз и оно понравилось 2.8 тысяч людям.