Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.3 / 3....
  • LibreOffice 3.6.6 / 4.0.3
  • MPlayer 1.1.1
  • systemd 204
  • Arch Linux 2013.05.01
  • Blender 2.67a
  • KDE Software Compilatio...
  • CrunchBang Linux Stable...
  • Elementary OS 0.1 / 0.2...
  • SystemRescueCd 3.6.0
  • Home > Linux > Programming > Libraries

    FEST-Mocks 1.0

    Download button

    No screenshots available
    Downloads: 438  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    Good (3.1/5)
    6 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Alex Ruiz | More programs
    The Apache License 2.0 / FREE
    December 12th, 2008, 10:43 GMT
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    FEST-Mocks description

    A Java library which mission is to minimize potential shortcomings of Mock Objects.

    FEST-Mocks is a Java library which mission is to minimize potential shortcomings of Mock Objects.

    EasyMockTemplate

    One of the shortcomings of using mocks is introduction of clutter and duplication in our code. Take a look at this example using EasyMock:

    @Test public void shouldAddNewEmployee() {
    mockEmployeeDAO.insert(employee);
    replay(mockEmployeeDAO);
    employeeBO.addNewEmployee(employee);
    verify(mockEmployeeDAO);
    }

    @Test public void shouldUpdateEmployee() {
    mockEmployeeDAO.update(employee);
    replay(mockEmployeeDAO);
    employeeBO.updateEmployee(employee);
    verify(mockEmployeeDAO);
    }


    The problems with the code listing above are the following:

    1. There is no clear separation of mock expectations and code to test
    2. Calls to replay and verify are duplicated
    3. It is easy to forget to call replay and verify in every test method, which will result in failing tests

    A solution to this problem is FEST's EasyMockTemplate:

    @Test public void shouldUpdateEmployee() {

    new EasyMockTemplate(mockEmployeeDao) {
    @Override protected void expectations() {
    mockEmployeeDAO.update(employee);
    }

    @Override protected void codeToTest() {
    employeeBO.updateEmployee(employee);
    }
    }.run();

    }


    - We have eliminated code duplication (calls replay and verify)
    - We have a clear separation of mock expectations and code to test
    - We no longer have to call replay and verify

    Product's homepage

    Requirements:

    · Java SE 5.0 or later

      


    TAGS:

    Mock Objects | Java library | Java class | Mock | Objects | Java

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM