From: Jeff M. <cus...@us...> - 2002-09-06 12:53:08
|
Update of /cvsroot/mockobjects/mockobjects-java/doc/html In directory usw-pr-cvs1:/tmp/cvs-serv5184/doc/html Modified Files: faq.html Log Message: Added some bits to the FAQ Index: faq.html =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/doc/html/faq.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- faq.html 2 Sep 2002 10:24:37 -0000 1.2 +++ faq.html 6 Sep 2002 12:53:04 -0000 1.3 @@ -2,11 +2,11 @@ <h2>General Questions About Mocks</h2> <h3>What's a mock object?</h3> - <p>A mock object is a "double agent" used to test the behavior + <p>A mock object is a "double agent" used to test the behaviour of other objects. First, a mock object acts as a faux implementation -of an interface or class that simulates the external behavior of a true implementation. +of an interface or class that mimics the external behaviour of a true implementation. Second, a mock object observes how other objects interact with its -methods and compares actual behavior with preset expectations. When a discrepancy +methods and compares actual behaviour with preset expectations. When a discrepancy occurs, a mock object can interrupt the test and report the anomaly. If the discrepancy cannot be noted during the test, a verification method called by the tester ensures that all expectations have been met or failures reported.<br> @@ -20,10 +20,10 @@ will be passed a certain set of parameters for use with a given SQL command. A mock object can be told to expect conditions such as these, so that it can report back when our expectations are not met. The MockObjects API has -refactored this mechanism into a framework of Expectation classes. </p> +re factored this mechanism into a framework of Expectation classes. </p> <h3>Why should I bother?</h3> -<p>Today, most developers recognize the value of unit testing. But many developers +<p>Today, most developers recognise the value of unit testing. But many developers also find that creating and maintaining non-trivial unit tests becomes difficult as products mature. Writing significant unit tests can tempt developers into making objects "test-aware". This can complicate production code and begins @@ -37,7 +37,7 @@ hardware devices.</p> <p> Mock objects can also simulate states that may be difficult or time-consuming -to realize in a runtime environment. A mock object can throw any exception +to realise in a runtime environment. A mock object can throw any exception or produce any error condition on demand. For example, using a real database, to see how an object will react to an offline database you would have to actually down the database. Using a mock JDBC connection, you can simulate @@ -62,7 +62,7 @@ without making changes to your production objects. Generally, the better designed your application, the easier it should be to test with mock objects. If an application does not test well, there are usually ways to improve its -design and provide better testability. In practice, many developers +design and provide better testability. In practise, many developers find that approaching new development with a test-first perspective helps them write better programs more quickly. Writing tests for features helps defines the objects we need to provide those features. Test-driven design @@ -71,9 +71,15 @@ <h3>What are some of the patterns used to create tests with mock objects?</h3> <h3>Who discovered mock objects?</h3> <h3>What is the difference between stub objects and mock objects?</h3> - - -<h2>About the Mock Object Implementation</h2> + <p> + A stub object is the most minimal implementation of a class providing +nothing more than the implementation of an interface. A mock object adds to this +the ability to preload an object with data which can be played back during a +test. In addition to this is can be given details of the expected interactions +that other objects will have with it and at the end of testing verify that these +have taken place. + </p> + <h2>About the Mock Object Implementation</h2> <h3>Why do I have to call setup???? to instead of set??? to add something to @@ -82,13 +88,24 @@ </p> - <h3>Who do I contribute changes back to the mock objects project?</h3> + <h3>How do I contribute changes back to the mock objects project?</h3> <p> + If you've made changes to any of the mock objects we'd love to see them an +hopefully include them back into our code base for other people to make use of. +The way to do this is to send them to our <a href="mailto:moc...@li...">development</a> mailing list. Our preferred format is to provide changes as unified diff format (diff -u), but anything will do really. </p> - <h3>What does it mean when I get a NotImplementedException?</h3> <p> + As a matter of course we try not to do anymore work than is necessary when +creating a mock. This means that if there are methods on a class which are not +used we don't write any mock code in them until someone has a need for it. In +order to make it easier to tell with methods have been implemented and which +haven't any method which has not been implemented will throw a +NotImplementedException when it is called. If this happens during a test you can +either write an implementation for the method and send us a patch for it, or +mail us with details of how you'd like to use the method and we'll try(spare +time permitting) to implement it. </p> @@ -118,7 +135,7 @@ <h3>Why are the internals of mock private when there just test class?</h3> - <h3>What is the best practice for integrating mocks into a project?</h3> + <h3>What is the best practise for integrating mocks into a project?</h3> <h2>Other Questions</h2> |