Episode 516: Brian Okken on Testing in Python with pytest

Topics covered
Popular Clips
Episode Highlights
TDD Approach
Test-driven development (TDD) is a powerful approach that emphasizes writing tests alongside production code. shares his perspective on TDD, highlighting its benefits in developing both tests and code simultaneously. He notes that while some advocate for writing tests first, he often writes tests during development to explore and understand code behavior. explains:
I use testing for just playing. So one of the things that people will often do when they're developing code, like if you're calling, like you're developing a bunch of functions within a module, say, I want to call those functions to see what they do.
---
This approach allows for flexibility and creativity in coding, enabling developers to refine their code without being constrained by initial test structures 1 2.
Modular Design
Writing tests can naturally lead to more modular and maintainable code structures. and discuss how starting with small, testable pieces encourages modular design, reducing code coupling and enhancing maintainability. Okken emphasizes the importance of designing for testing, suggesting that even simple scripts should be structured to allow for easy testing. He advises:
Breaking your code into different functions, different modules is a good thing because then I can test individual pieces.
---
This modular approach not only facilitates testing but also supports refactoring, ensuring that changes do not inadvertently break existing functionality 3 4.
Related Episodes


Episode 431: Ken Youens-Clark on Learning Python
Answers 383 questions

Episode 167: The History of JUnit and the Future of Testing with Kent Beck
Answers 383 questions
SE Radio 589: Zac Hatfield-Dodds on Property-Based Testing in Python
Answers 383 questions

366: Test Automation
Answers 383 questions

SE-Radio Episode 256: Jay Fields on Working Effectively with Unit Tests
Answers 383 questions

SE Radio 572: Gregory Kapfhammer on Flaky Tests
Answers 383 questions

Episode 155: Johannes Link & Lasse Koskela on TDD
Answers 383 questions

Episode 70: Gerard Meszaros on XUnit Test Patterns
Answers 383 questions

Episode 474: Paul Butcher on Fuzz Testing
Answers 383 questions

Episode 521: Phillip Mayhew on Test Automation in Gaming
Answers 383 questions

Episode 526: Brian Campbell on Proof of Possession Defenses
Answers 383 questions

Episode 367: Diomidis Spinellis on Debugging
Answers 383 questions

Episode 441 Shipping Software - With Bugs
Answers 383 questions

Episode 461 Michael Ashburne and Maxwell Huffman on Quality Assurance
Answers 383 questions
Episode-467-Kim-Carter-on-Dynamic-Application-Security-Testing
Answers 383 questions













