We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

Managing Mocks

Formale Metadaten

Titel
Managing Mocks
Serientitel
Teil
69
Anzahl der Teile
169
Autor
Lizenz
CC-Namensnennung - keine kommerzielle Nutzung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben
Identifikatoren
Herausgeber
Erscheinungsjahr
Sprache

Inhaltliche Metadaten

Fachgebiet
Genre
Abstract
Helen Sherwood-Taylor - Managing Mocks Mocking is a valuable technique for writing tests but mocking effectively is often a stumbling block for many developers and can raise questions about its overall value as a technique. There will be a brief introduction to mocking, then a look at features and techniques of Python’s unittest.mock library and cover some useful tips and common scenarios, so this will be useful to those who have some experience mocking but would like to do so more effectively. ----- Mocking is a valuable technique for writing tests but mocking effectively is often a stumbling block for many developers and can raise questions about its overall value as a technique. The audience will have some familiarity with unit testing and may have tried mocking before, but some introduction will be provided for those who haven’t. We will look at some features and techniques of Python’s unittest.mock library and cover some useful tips and common scenarios, so this will be useful to those who have some experience mocking but would like to do so more effectively. Summary of proposed content: 1. A short introduction to what mocking is and why it is useful. 2. Tour of Python’s mock library and how to make the most of it * Creating and manipulating Mock objects * Setting up return values and side effects to control test environment * Inspecting mocks - different ways to examine a mock object and find out what happened during the test * How and where to patch 3. Common mocking situations - scenarios where mocking is particularly useful and/or tricky to get right. For example - date/time, filesystem, read only properties 4. Some discussion of when mocking is and isn't helpful. Focus will be mainly on Python's unittest.mock module but we will also have a brief look at some other useful libraries.