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

Published: 19 October 2021
on channel: 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


Watch video How to make code more testable, by factoring out and abstracting side effects online without registration, duration hours minute second in high quality. This video was added by user Studying With Alex 19 October 2021, don't forget to share it with your friends and acquaintances, it has been viewed on our site 52,427 once and liked it 2.8 thousand people.