In order to enhance the productivity of developer and the software, we use JUnit and EasyMock which are basically best choices for testing tools. JUnit is done by isolating a single component from the rest. The method goes in four sections and thus a cycle is completed. In case of EasyMock, it is the method by which one isolates the component from the rest of the system as all of them are dependent on each other.
JUnit:
JUnit is performed in four phases and is done in isolated components in a repeatable way. The four phases are as follows:
- Prepare: In this phases, the system sets up a baseline in order to test and it also defines the test result.
- Execution: The Test starts now.
- Validation: The system validates the result against the previous expectations or estimations.
- Reset: The whole unit is set back to the original way like it was before prepare phase.
JUnit is a popular framework that is used for testing purpose of isolated components as it has effective API.
Important Characteristics of JUnit:
- JUnit is known to be an open source network for testing and writing codes.
- JUnit provides test runners for running tests.
- It gives you the facility of writing codes fast and helps you in running it.
- Two bars are there in order to display progress and report. If the bar is green then the test is running smoothly else if red then test failed.
Overview of EasyMock:
Before we understand EasyMock, we need to understand Mock Objects. Mark Object facilitates the running and testing of codes by JUnit. To test a component, one needs to isolate it from the rest as they are interconnected and are independent to each other. The Job of Mock Object is to isolate the component and this is done by EasyMock.
EasyMock is a framework that creates Mock Object which in return isolates the component in order to run. After the creation of Mock Object, a proxy object is created which takes the place of real object.
Life Cycle of EasyMock:
- Create Mock: In this phase, the mock object is created
- Expect: In this, the expected behavior of the mock object is recorded and in the later phase, it is verified.
- Replays: This phase replays the previously recorded behavior.
- Verification: This is the last phase where the recorded mock object is executed and if passed then the phase is complete.
JUnit and EasyMock work in collaboration as both are interdependent to easy other. One needs to test components and the other creates viable situation to run testing.