Files changed (10)
++ constraint base class to allow non-derived constraints to default to an equality match against the parameter. Would allow more compact argument constraints for the common case of equality e.g. mock.foo('bar').will(...)
+<p>pMock is a Python module for testing Python code using <a href="http://www.mockobjects.com">mock objects</a>.</p>
+<p>Inspired by the Java <a href="http://www.jmock.org">jMock</a> library, pMock makes the writing of unit tests using mock object techniques easier.</p>
+See the <a href="overview.html">overview</a> for an introduction on how to use pMock in your unit tests.
+<p>Browse the <a href="http://cvs.sourceforge.net/viewcvs.py/pmock/pmock/src/">source</a> in CVS</p>
+<a href="http://sourceforge.net"><img src="http://sourceforge.net/sflogo.php?group_id=104082&type=1" width="88" height="31" border="0" alt="SourceForge.net Logo" /></a>
+<li><a href="#DefaultBehaviourForUndefinedMethods">Default behaviour for undefined methods<a/></li>
+A mock object is created to represent a real object for the purposes of a unit test. Using a mock object rather than the real object can be useful if the real object is difficult to construct, hasn't been written yet or causes awkward side effects in use.
+<p>When the mock objects have been set up, they are then used in the unit test as the real objects would have been.
+After the test's normal assertions have been made, an assertion that the mock's expectations have been satisfied should be made.
+If any of the mock's expectations haven't been satisfied, such as an expected method not having been called, then the <code>verify</code> call raises an exception.
+The arguments to the expectation's mocked method are constraint objects which are evaluated on the actual arguments when a call is made to the mock object. If an argument doesn't satisfy its constraint then the expectation remains unsatisfied.
+The argument to the <code>expects</code> method describes how often the expected method can be called.
+<p>An explicit id can be set for an expectation and used in the <code>after</code> method instead of using the method name.
+Stubs allow behaviours to be specified for methods that can be called any number of times and are not to be included in the mock's verification check.
+When an undefined method is called an exception is normally raised. However this behviour can be overridden by supplying a stub object to the <code>Mock</code> instance's <code>set_default_stub</code> method.
+The test code can be made more concise by importing the pmock module's public classes and functions into the test module.
+The <code>MockTestCase</code> class is a convenience base class for tests. It provides the <code>mock</code> method for creating mock objects that will be automatically verified after the test method has run. The verify calls are considered to be part of the test and so are made to the mock object before <code>tearDown</code> has been called.
+<p>Looking at the pMock <a href="http://cvs.sourceforge.net/viewcvs.py/pmock/pmock/src/acceptance_tests.py">acceptance tests</a> may be helpful in further clarifying the behaviour of the module.</p>
+<p>The <a href="http://www.mockobjects.com">mock objects</a> and <a href="http://www.jmock.org">jmock</a> websites contain useful information on mock objects and their use as a testing technique.</p>
+<p>Martin Fowler has written an <a href="http://martinfowler.com/articles/mocksArentStubs.html">interesting article about mock objects</a> and the style of unit testing that uses them.</p>
+<p>Nat Pryce, one of the jmock authors, has written <a href="http://nat.truemesh.com/archives/000342.html">a response</a> to Martin Fowler's article.</p>