How To Write Unit Tests For Existing Python Code // Part 1 of 2

Описание к видео How To Write Unit Tests For Existing Python Code // Part 1 of 2

In this video, I show you a practical example of adding unit tests to existing code. This first part focuses on adding tests while not changing the original code. In the second part (coming out next week), I'll show how refactoring the code simplifies test writing while also improving the design.

NOTES:

1) There are a few things in the test setup that are not ideal, like how dates are used in the test code, using a real API key, and doing actual card charges. I'll address these things in part 2.

2) patching means that you're replacing a dependency in a function or method with something else. The thing that you replace it with is called a mock (apologies, my use of the terms in the video is a bit messy).

The code I worked on in this episode is available here: https://github.com/ArjanCodes/2022-te....

💡 Get my FREE 7-step guide to help you consistently design great software: https://arjancodes.com/designguide.

💻 ArjanCodes Blog: https://www.arjancodes.com/blog

🎓 Courses:
The Software Designer Mindset: https://www.arjancodes.com/mindset
The Software Designer Mindset Team Packages: https://www.arjancodes.com/sas
The Software Architect Mindset: Pre-register now! https://www.arjancodes.com/architect
Next Level Python: Become a Python Expert: https://www.arjancodes.com/next-level...
The 30-Day Design Challenge: https://www.arjancodes.com/30ddc

🛒 GEAR & RECOMMENDED BOOKS: https://kit.co/arjancodes.

👍 If you enjoyed this content, give this video a like. If you want to watch more of my upcoming videos, consider subscribing to my channel!

💬 Discord: https://discord.arjan.codes
🐦Twitter:   / arjancodes  
🌍LinkedIn:   / arjancodes  
🕵Facebook:   / arjancodes  

👀 Code reviewers:
- Yoriz
- Ryan Laursen
- Sybren A. Stüvel
- Dale Hagglund

🎥 Video edited by Mark Bacskai:   / bacskaimark  

🔖 Chapters:
0:00 Intro
1:05 Explaining the example
4:10 Analysis & Setup
6:05 Adding LineItem tests
8:40 Adding Order tests
10:56 Adding PaymentProcessor tests
15:50 Analysis of the test setup so far
17:05 Adding pay_order tests



#arjancodes #softwaredesign #python

DISCLAIMER - The links in this description might be affiliate links. If you purchase a product or service through one of those links, I may receive a small commission. There is no additional charge to you. Thanks for supporting my channel so I can continue to provide you with free content each week!

Комментарии

Информация по комментариям в разработке