Tuesday, January 22, 2008

Will Shaving Trigger A Herpe Outbreak



EasyMock is a library useful for unit testing with JUnit (or derivative as TestNG). We use it to create anything ghost or mockery (mock) and to return a particular result for a specific input.

For example, if we want to test a service that needs a DAO to get information, we can create a ghost DAO (mock) to perform such function units and try to get rid of a unified service.

This is achieved based testing methods in checking the correctness of its internal code (white box testing).

steps required in each test:

- Need JDK 5 or higher.

- Preparing the Environment: import libraries TestNG and EasyMock in Eclipse: www.easymock.org and www.testng.org .

- Creating the mock object.

- Reset the mock object.

- Except than it receives and returns that object. Your call is optional, but not the function call (it is clearer in the examples).

- Replay that prepares the object for testing.

- Call function that is going to prove (directly or indirectly, but the code must execute a mock object's method we have defined).

- Verify the mock object created.

0 comments:

Post a Comment