EasyMock is an
open-source
Open source is source code that is made freely available for possible modification and redistribution. Products include permission to use the source code, design documents, or content of the product. The open-source model is a decentralized sof ...
testing framework for
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
released under the
Apache License.
The framework allows the creation of
test double In computer programming and computer science, programmers employ a technique called automated unit testing to reduce the likelihood of bugs occurring in the software. Frequently, the final release software consists of a complex set of objects or ...
objects for the purpose of
Test-driven Development
Test-driven development (TDD) is a software development process relying on software requirements being converted to test cases before software is fully developed, and tracking all software development by repeatedly testing the software against al ...
(TDD) or
Behavior Driven Development
In software engineering, behavior-driven development (BDD) is an agile software development process that encourages collaboration among developers, quality assurance experts, and customer representatives in a software project. It encourages teams ...
(BDD).
Research performed in 2013 on 10,000 GitHub projects found that EasyMock is the 32nd most popular Java library.
Features
The EasyMock provides dynamically generated
Mock object
In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
s (at runtime), without having to implement them. In EasyMock, the definition of Mock Object is differed from using an implemented Mock Object. Mock objects are built at run time and additional implementations cannot be defined for those objects.
Origin
EasyMock was created by Tammo Freese in 2001 (at OFFIS). Originally it allowed only mock interfaces, with type safe mocking and additional features were added in later developments. Most notably, class mocking was added by Henri Tremblay, the current lead developer, in 2003.
Usage
EasyMock can be used in application with often-changing interfaces.
Example
Simple currency exchange program is provided here.
An interface may look like as follows:
import java.io.IOException;
public interface ExchangeRate
Implementation for a concrete class may look like as follows:
import java.io.IOException;
public class Currency
Sample implementation for a test class may look like as follows:
import junit.framework.TestCase;
import org.easymock.EasyMock;
import java.io.IOException;
public class CurrencyTest extends TestCase
See also
*
Behavior driven development
In software engineering, behavior-driven development (BDD) is an agile software development process that encourages collaboration among developers, quality assurance experts, and customer representatives in a software project. It encourages teams ...
*
Mock object
In object-oriented programming, mock objects are simulated objects that mimic the behaviour of real objects in controlled ways, most often as part of a software testing initiative. A programmer typically creates a mock object to test the behaviou ...
*
List of unit testing frameworks
This article is a list of tables of code-driven unit testing frameworks for various programming languages. Some, but not all, of these are based on xUnit.
Columns (classification)
* Name: This column contains the name of the framework and w ...
*
Software testing
Software testing is the act of examining the artifacts and the behavior of the software under test by validation and verification. Software testing can also provide an objective, independent view of the software to allow the business to apprecia ...
*
Unit testing
In computer programming, unit testing is a software testing method by which individual units of source code—sets of one or more computer program modules together with associated control data, usage procedures, and operating procedures&md ...
References
External links
*
* {{GitHub, https://github.com/easymock/easymock
Unit testing frameworks