Borland Developer Network

Borland Delphi Partner CD

Delphi

Lite

POCMock

POMock v3.0.2 Standard

POCMock (ID #22586)


Pretty Objects Computers inc.

We all want the best products, especially those that offer the very best in quality.

Automatic unit testing is the best guarantee of quality. One very good tool makes it possible to attain this goal : NUnit.

Unfortunately, it is not enough!
Unit testing is carried out from outside the code to test: we only test the use of the classes, methods, properties… but we do not know what goes on inside. We do not know if the problem is in our class or in another class used by our class (classes over which we have no control, like those found in Microsoft.NET Framework, those of third-parties, etc.)

The following is a list of typical problems:

How can we isolate the class we want to test if it uses other classes?
Is the problem in our class?

What about those problems that we cannot reproduce automatically?
How do you test the behaviour of our software if the network goes down?

What about rare and infrequent situations?
Imagine that we have to perform a task on February 29 only. Do we have to carry out one test every four years? Do we have to change the clock every time we perform a test?

What about the availability of necessary resources to carry out the testing?
Does every developer need to have a database, a Web server, etc. to avoid conflicts during development?

How much time is needed before getting to what you really want to test?
Connecting and disconnecting from a database takes time. To conduct independent testing, this has to be done for each test and we have hundreds of tests to do!


Mocking enables you to simulate classes so that all these problems does not occurs: You call the method to test within your NUnit test (or any other test environment), and this method use the lower level classes that you simulate when mocking them. All what you have to do is specifying in your test code what calls will be done to these low level classes, what the parameters constraints are, what to return to the calling code (the code to test) in order to simulate them.

So, you can proceed the tests very quickly, without using any real resource, you can simulate troubles....

Install POCMock

POCMock home page