Название: Speed Up Your Django Tests Автор: Adam Johnson Издательство: Adam’s Web Services Ltd Год: 2021-07-08 Страниц: 198 Язык: английский Формат: pdf (true), epub +code Размер: 14.9 MB
This book is a practical guide to making your Django project's tests faster. It has many tips and tricks that apply to all projects, big and small. And it covers the two most popular test runners: Django's test framework and Pytest. It's based on my experience speeding up various Django projects' test suites, improving Django's own testing framework, and creating Pytest plugins.
The first two chapters, Toolbox and Measure!, explain the various tools you have at hand for modifying and measuring your tests respectively. The next six chapters cover ways of speeding up your tests without the bother of rewriting your test code (much). Easy Wins covers a number of smaller, non-invasive changes that can speed up your tests. Upgrades then re-iterates the importance of keeping things upgraded, especially with respect to test performance. Parallelize covers using parallelized testing, and the challenges you might face adding it. Migrations covers tactics for improving your workflow with database migrations. Finally, Database Configuration and CI Configuration cover ways of speeding up your tests in configuration for those environments. The three chapters that follow cover how to write fast tests. Test Structure and Test Data go into depth on writing faster tests that use less data. And Targeted Mocking shows some focussed techniques for replacing components during testing that can help you write better, faster tests. Finally, the Outroduction gives some closing remarks and links to further reading.
Examples have been prepared with Python 3.9 and Django 3.2. I’m only using the official Python distribution, CPython, since Django or its dependencies often don’t work on other Python interpreters.
Who Is This Book For? If you are a Django developer working with tests, this is for you. No matter your level. My aim is to make the book readable by a junior developer who has been given the vague task of “improving the tests”, but also to include material that even long time Django users may not have come across. I’ve tried to be opinionated enough to be actionable, but provide advice that’s applicable to all projects.
Contents: The book contains 13 chapters:
1. Introduction - Opening notes, how to use the book. 2. Toolbox - A tour of the various tools you can use to change how your tests run. 3. Measure! - The importance of profiling, with walkthroughs using two different profilers on a test suite. 4. Easy Wins - 11 things you can do in 5 minutes to speed up your test suite. 5. Upgrades - The importance of upgrades, and some how-to guidance to get them done easily. 6. Parallelize - How to use test suite parallelization to boost your tests. 7. Migrations - Reduce the overhead of building your test database. 8. Database Configuration - Tweak your database's configuration to get more speed. 9. CI Configuration - And tweak your CI configuration to boost test speed too. 10. Test Structure - Notes on the best structure for fast, accurate tests, and ways you can restructure. 11. Test Data - The best strategies for creating data in your tests. 12. Targeted Mocking - A guide to mocking, and the best libraries for mocking out specific things such as HTTP requests and time. 13. Outroduction - Closing notes with extra links.
Внимание
Уважаемый посетитель, Вы зашли на сайт как незарегистрированный пользователь.
Мы рекомендуем Вам зарегистрироваться либо войти на сайт под своим именем.
Информация
Посетители, находящиеся в группе Гости, не могут оставлять комментарии к данной публикации.