Test-driven Python development : develop high-quality and maintainable Python applications using the principles of test-driven development /
Annotation
Clasificación: | Libro Electrónico |
---|---|
Autor principal: | |
Formato: | Electrónico eBook |
Idioma: | Inglés |
Publicado: |
Birmingham :
Packt Publishing,
2015.
|
Colección: | Community experience distilled.
|
Temas: | |
Acceso en línea: | Texto completo Texto completo |
Tabla de Contenidos:
- Cover; Copyright; Credits; About the Author; Acknowledgments; About the Reviewers; www.PacktPub.com; Table of Contents; Preface; Chapter 1: Getting Started with Test-driven Development; Prerequisites; Understanding test-driven development; TDD versus unit testing versus integration testing; Using TDD to build a stock alert application; Writing our first test; Analyzing the test output; Test errors versus test failures; Making the test pass; Reorganizing the test code; Running the tests after the reorganization; Summary; Chapter 2: Red-Green-Refactor
- The TDD Cycle
- Tests are executable requirementsArrange-Act-Assert; Documenting our tests; Testing for exceptions; Exploring assert methods; Specific asserts versus generic asserts; Setup and teardown; Brittle tests; Refactoring the design; Refactoring tests; Exploring the Rule classes; Exercise; Summary; Chapter 3: Code Smells and Refactoring; A dual crossover moving average; Implementing the dual crossover moving average; Identifying code smells; Refactoring; The Rename Variable and Rename Method refactorings; Commenting Styles; Replace Magic Literals with Constants; The Extract Method refactoring
- Replace Calculation with Temporary VariableExtract Conditional to Method; The DRY principle; Single Responsibility Principle; Extract Class; Move Method to Class; The importance of tests; Exercise; Wrapping up; Summary; Chapter 4: Using Mock Objects to Test Interactions; Hand writing a simple mock; Using the Python mocking framework; Mocking objects; Mocking return values; Mocking side effects; How much mocking is too much?; Mocks versus stubs versus fakes versus spies; Patching methods; An important gotcha when patching; Tying it all together; Summary; Chapter 5: Working with Legacy Code
- What is legacy code?Understanding the code; What are characterization tests?; Using the Python interactive shell to understand the code; Writing a characterization test; Using pdb to understand the code; Some common pdb commands; Walking through a pdb session; Techniques to break dependencies; The Rope refactoring library; Separate initialization from execution; Use default values for parameters; Extract the method and test; Inject dependencies; Inherit and test; Stubbing local methods; Extract the method and stub; The cycle continues; Time to refactor; Long-term refactoring; Summary
- Chapter 6: Maintaining Your Test SuiteGoals of test maintenance; Organizing tests; Filesystem layout; Naming conventions; Test suite grouping; Making tests readable; Using docstrings; Using fixtures; Fixtures and patching; Using a custom test case class hierarchy; Writing tests closer to the domain; Writing helper methods; Writing better asserts; Using custom equality checkers; Using matchers; Summary; Chapter 7: Executable Documentation with doctest; Our first doctest; Running the doctest; Test failures; Testing for exceptions; Package-level doctests; Maintaining doctests