404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.117.99.230: ~ $
.. index::
    single: Cookbook; Default Mock Expectations

Default Mock Expectations
=========================

Often in unit testing, we end up with sets of tests which use the same object
dependency over and over again. Rather than mocking this class/object within
every single unit test (requiring a mountain of duplicate code), we can
instead define reusable default mocks within the test case's ``setup()``
method. This even works where unit tests use varying expectations on the same
or similar mock object.

How this works, is that you can define mocks with default expectations. Then,
in a later unit test, you can add or fine-tune expectations for that specific
test. Any expectation can be set as a default using the ``byDefault()``
declaration.

Filemanager

Name Type Size Permission Actions
big_parent_class.rst File 1.63 KB 0644
class_constants.rst File 4.57 KB 0644
default_expectations.rst File 757 B 0644
detecting_mock_objects.rst File 394 B 0644
index.rst File 273 B 0644
map.rst.inc File 275 B 0644
mockery_on.rst File 2.98 KB 0644
mocking_class_within_class.rst File 4.31 KB 0644
mocking_hard_dependencies.rst File 4.37 KB 0644
not_calling_the_constructor.rst File 2.1 KB 0644