I was under the impression they were used for emulating objects/systems which don't exist.
For instance if you have a User class with createUser, updateUser, etc type methods...and you test each method...but each method interacts with a database...I assumed a Mock object was intended to replace or emulate a DB server...
This confused me because that would be a HELLUVA lot of work...and if the Mock object simply return TRUE then your code isn't exactly tested...because passing a SQL query which is flawed would cause the RDBMS to return false NOT true...
The it dawns on me...why wouldn't a DB server be available to a developer writting production code and *not* the developer writing tests???
So I assume my understanding of Mock objects were off??? *lol* The same environment should be made available to both test writers and system developers...
I assume a setUp and tearDown method would be responsible for creating a new DB connection, creating tables, etc...so a unit test could do it's actual magic without changing a production database...
Is this what Mock objects do? They are created to avoid possibly setting up a DB and tearing it down on every unit test invocation...instead you create the object once and leave it???
Cheers