Blame | Letzte Änderung | Log anzeigen | RSS feed
.. index::single: Cookbook; Default Mock ExpectationsDefault Mock Expectations=========================Often in unit testing, we end up with sets of tests which use the same objectdependency over and over again. Rather than mocking this class/object withinevery single unit test (requiring a mountain of duplicate code), we caninstead define reusable default mocks within the test case's ``setup()``method. This even works where unit tests use varying expectations on the sameor 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 specifictest. Any expectation can be set as a default using the ``byDefault()``declaration.