Hammock 1.6 (Default branch)


 
Thread Tools Search this Thread
Special Forums News, Links, Events and Announcements Software Releases - RSS News Hammock 1.6 (Default branch)
# 1  
Old 02-02-2009
Hammock 1.6 (Default branch)

Hammock is a mock object framework for J2ME devices. It is used in conjunction with unit test frameworks like JMUnit and J2MEUnit. The framework includes mocks for many of the J2ME UI and I/O classes as well as a utility, HammockMaker, for generating mocks of other classes. License: The Apache License 2.0 Changes:
This release adds better support for spy objects. Developers who prefer the Arrange-Act-Assert (AAA) idiom to record-and-replay may like to use the new coding style supported by the spy objects. Image

Image

More...
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question
Test::MockModule(3pm)					User Contributed Perl Documentation				     Test::MockModule(3pm)

NAME
Test::MockModule - Override subroutines in a module for unit testing SYNOPSIS
use Module::Name; use Test::MockModule; { my $module = new Test::MockModule('Module::Name'); $module->mock('subroutine', sub { ... }); Module::Name::subroutine(@args); # mocked } Module::Name::subroutine(@args); # original subroutine DESCRIPTION
"Test::MockModule" lets you temporarily redefine subroutines in other packages for the purposes of unit testing. A "Test::MockModule" object is set up to mock subroutines for a given module. The object remembers the original subroutine so it can be easily restored. This happens automatically when all MockModule objects for the given module go out of scope, or when you "unmock()" the subroutine. METHODS
new($package[, %options]) Returns an object that will mock subroutines in the specified $package. If there is no $VERSION defined in $package, the module will be automatically loaded. You can override this behaviour by setting the "no_auto" option: my $mock = new Test::MockModule('Module::Name', no_auto => 1); get_package() Returns the target package name for the mocked subroutines is_mocked($subroutine) Returns a boolean value indicating whether or not the subroutine is currently mocked mock($subroutine => &coderef) Temporarily replaces one or more subroutines in the mocked module. A subroutine can be mocked with a code reference or a scalar. A scalar will be recast as a subroutine that returns the scalar. The following statements are equivalent: $module->mock(purge => 'purged'); $module->mock(purge => sub { return 'purged'}); $module->mock(updated => [localtime()]); $module->mock(updated => sub { return [localtime()]}); However, "undef" is a special case. If you mock a subroutine with "undef" it will install an empty subroutine $module->mock(purge => undef); $module->mock(purge => sub { }); rather than a subroutine that returns "undef": $module->mock(purge => sub { undef }); You can call "mock()" for the same subroutine many times, but when you call "unmock()", the original subroutine is restored (not the last mocked instance). original($subroutine) Returns the original (unmocked) subroutine unmock($subroutine [, ...]) Restores the original $subroutine. You can specify a list of subroutines to "unmock()" in one go. unmock_all() Restores all the subroutines in the package that were mocked. This is automatically called when all "Test::MockObject" objects for the given package go out of scope. SEE ALSO
Test::MockObject::Extends Sub::Override AUTHOR
Simon Flack <simonflk _AT_ cpan.org> COPYRIGHT
Copyright 2004 Simon Flack <simonflk _AT_ cpan.org>. All rights reserved You may distribute under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. perl v5.10.0 2005-03-24 Test::MockModule(3pm)