- EasyMock - Discussion
- EasyMock - Useful Resources
- EasyMock - Quick Guide
- EasyMock - createNiceMock
- EasyMock - createStrictMock
- EasyMock - createMock
- EasyMock - Exception Handling
- EasyMock - Varying Calls
- EasyMock - Expecting Calls
- EasyMock - Verifying Behavior
- EasyMock - Adding Behavior
- EasyMock - JUnit Integration
- EasyMock - First Application
- EasyMock - Environment Setup
- EasyMock - Overview
- EasyMock - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
EasyMock - Environment Setup
This chapter takes you through the process of setting up EasyMock on Windows and Linux based systems. EasyMock can be easily installed and integrated with your current Java environment following a few simple steps without any complex setup procedures. User administration is required while installation.
System Requirements
JDK | Java SE 2 JDK 1.5 or above |
---|---|
Memory | 1 GB RAM (recommended) |
Disk Space | No minimum requirement |
Operating System Version | Windows XP or above, Linux |
Let us now proceed with the steps to install EasyMock.
Step 1: Verify your Java Installation
First of all, you need to have Java Software Development Kit (SDK) installed on your system. To verify this, execute any of the two commands depending on the platform you are working on.
If the Java installation has been done properly, then it will display the current version and specification of your Java installation. A sample output is given in the following table.
Platform | Command | Sample Output |
---|---|---|
Windows | Open command console and type: >java –version |
java version "11.0.11" 2021-04-20 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.11+9-LTS-194) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.11+9-LTS-194, mixed mode) |
Linux | Open command terminal and type: $java –version |
java version "11.0.11" 2021-04-20 LTS Open JDK Runtime Environment 18.9 (build 11.0.11+9-LTS-194) Open JDK 64-Bit Server VM (build 11.0.11+9-LTS-194, mixed mode) |
We assume the readers of this tutorial have Java SDK version 11.0.11 installed on their system.
In case you do not have Java SDK, download its current version from
and have it installed.Step 2: Set your Java Environment
Set the environment variable JAVA_HOME to point to the base directory location where Java is installed on your machine. For example,
Sr.No. | Platform & Description |
---|---|
1 | Windows Set JAVA_HOME to C:ProgramFilesjavajdk11.0.11 |
2 | Linux Export JAVA_HOME = /usr/local/java-current |
Append the full path of Java compiler location to the System Path.
Sr.No. | Platform & Description |
---|---|
1 | Windows Append the String "C:Program FilesJavajdk11.0.11in" to the end of the system variable PATH. |
2 | Linux Export PATH = $PATH:$JAVA_HOME/bin/ |
Execute the command java -version from the command prompt as explained above.
Step 3: Install EasyMock Library
Download the latest version of EasyMock from
and unzip its contents to a folder from where the required pbraries can be pnked to your Java program. Let us assume the files are collected in a folder on C drive.Add the complete path of the required jars as shown below to the CLASSPATH.
Sr.No. | Platform & Description |
---|---|
1 | Windows Append the following strings to the end of the user variable CLASSPATH − C:easymockeasymock-4.3.jar; |
2 | Linux Export CLASSPATH = $CLASSPATH: /usr/share/easymockeasymock-4.3.tar: |
Step 4: Download JUnit Archive
Download the latest version of JUnit jar file from
. Save the folder at the location C:>Junit.OS | Archive name |
---|---|
Windows | junit4.13.2.jar, hamcrest-core-1.3.jar |
Linux | junit4.13.2.jar, hamcrest-core-1.3.jar |
Step 5: Set JUnit Environment
Set the JUNIT_HOME environment variable to point to the base directory location where JUnit jars are stored on your machine. The following table shows how to set this environment variable on different operating systems, assuming we ve stored junit4.13.2.jar and hamcrest-core-1.3.jar at C:>Junit.
OS | Output |
---|---|
Windows | Set the environment variable JUNIT_HOME to C:JUNIT |
Linux | export JUNIT_HOME=/usr/local/JUNIT |
Step 6: Set CLASSPATH Variable
Set the CLASSPATH environment variable to point to the JUNIT jar location. The following table shows how it is done on different operating systems.
OS | Output |
---|---|
Windows | Set the environment variable CLASSPATH to %CLASSPATH%;%JUNIT_HOME% junit4.13.2.jar;%JUNIT_HOME%hamcrest-core-1.3.jar;. |
Linux | Export CLASSPATH=$CLASSPATH:$JUNIT_HOME/ junit4.13.2.jar:$JUNIT_HOME/hamcrest-core-1.3.jar:. |