Sergeonclear

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Tuesday, March 29, 2011

Mock Mock Mock

Posted on 2:56 AM by Unknown

Mocking is serious business for evolved coding monkeys these days. There are few good frameworks which help in mocking like easymock, jMockit, mockrunner etc

PowerMock
SmartGWT is a GWT widget library which has design issues as its classes doesnt mostly implement interfaces. But the problem is we have to use it as it has nice widgets.

Question: how do we unit test these classes which have native code and hard to mock?
 Powermock came to rescue us. It can re-engineer the class and supress static block and method.
Eg:
@RunWith(PowerMockRunner.class)
@PrepareForTest( {Appender.class})
@SuppressStaticInitializationFor({"com.google.gwt.user.client.ui.UIObject","com.smartgwt.client.widgets.BaseWidget"})
@MockPolicy({Slf4jMockPolicy.class, Log4jMockPolicy.class})
public class MyStaticTest{
}
The above supresses static blocks which have wierd native calls and helps us continue our junit as usual. But its a bit slow (worth it i believe).
More on usage here



jMock vs. EasyMock

Comparison of jmock & easy mock

Both have similar features. jMock has a DSL (domain specific language) while easy mock has record-replay style.

Apparently jMock seems to be better in terms of readability and usability. Would prefer the more intuitive framework like jMock than Easy mock.

Will post more when I actually try using jMock. Till than easy mock.

Useful links
1. EasyMock http://www.easymock.org
2. JMock  http://www.jmock.org
3. Mackinnon, T., et al. 2000. Endo-Testing: Unit Testing with Mock Objects. In Proceedings of XP 2000. http://www.mockobjects.com/files/endotesting.pdf
4. Freeman, S., et al. 2004. Mock Roles, not Objects. In Proceedings of OOPLSA 2004. http://www.mockobjects.com/files/mockrolesnotobjects.pdf
5. Walls, C. 2008. Spring in Action, 2nd Edition. Manning Publications Co., Greenwich, CT. §B.2.1.
6. Stewart, S. 2004. Approaches to Mocking. http://www.onjava.com/lpt/a/4526
7. Fowler, M. 2007. Mocks Aren't Stubs. http://martinfowler.com/articles/mocksArentStubs.html




Email ThisBlogThis!Share to XShare to Facebook
Posted in easy mock jmock vs mocking java tdd | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Cobertura- junit coverage tool
    First, you need to add a task definition to the build.xml file. This top-level taskdef element specifies that the cobertura.jar file is i...
  • Texter - An auto text expander
    I just cant imagine how many times I would have typed the same sentence again and again... Texter to the rescue.... thanks to  Adam Pash !! ...
  • setting up a static ip with SKY broadband
    Setting up a static ip on SKY broadband log into the router Navigate to LAN IP SET UP under advanced settings. Click add under address reser...
  • Troubleshooting Oracle connections related problem
    /* Display the number of sessions created for this db connection */ select username,schemaname, osuser,machine, terminal, program, type, mod...
  • Xpath
    XPath uses path expressions to select nodes or node-sets in an XML document. It contains a library of standard functions and is a major elem...
  • Textpad tricks
    Textpad tricks Find and replace Input : 66 Urology & Nephrology 737 Spermatogenesis Replace : the bold text in the above input Find Patt...
  • Oracle fix for schema table prefix and running scripts from sql developer
    In oracle it appears like a NON_OWNER user though granted access(select, insert, delete, update) to tables created by OWNER of the table ca...
  • SCRUM
    A mind map : http://www.mp3monster.org/new/techie/MindMaps/SCRUM.shtml
  • External Javascript from Java Servlets
    Copied from http://myappsecurity.blogspot.com/2007/01 Like to thank anurag for the content. /breaking-same-origin-barrier-of.html External ...
  • Spring method interceptors
    An excellent feature of spring AOP http://www.javalobby.org/java/forums/t44746.html Excellent podcast spanning from spring framework, AJAX t...

Categories

  • AJAX javascript
  • All about UK Visa HSMP VS H1
  • All about UK Visa HSMP VS H1 hsmp assistance
  • amazon
  • android apps ship control radio hindi
  • Apache 2.x setup Quick guide for Linux
  • apache commons configurator usage
  • apache commons usage
  • arsenals for developers
  • article
  • Batch script to load developer environment
  • Blind folded chess
  • Castor castor convert dtd to xsd
  • cloud comparision price
  • cloud comparison blog
  • cloud computing monthly price
  • cloud usage
  • Cobertura- junit coverage tool
  • Code generators
  • cron jobs expressions
  • cruisecontrol cruise control
  • debugging eclipse tips
  • developer tools
  • document library
  • easy mock jmock vs mocking java tdd
  • External Javascript from Java Servlets
  • fedora 9 lenovo 3000 n200 windows xp dual boot problem
  • Fire fox plugins and tweaks
  • Free PHP hosting
  • gods debris the religion war scott adams dilbert
  • google app engine
  • gwt javascript
  • hibernate second level cache
  • i18n locale localization internationalization spring liferay portlet locale
  • ibatis sybase mapping
  • image gallery
  • iphone apps bri8 apple
  • iphone shsh 3gs ipsw downgrade ifaith tinyumbrella ios5.1.1 to ios5.0
  • java
  • java JDBC
  • javascript junit testing
  • Javascript trouble shooting tool
  • Jboss overview
  • jmeter load testing custom java sampler javasamplerclient xml test
  • JNDI test JSP page
  • Joomla CMS
  • JProfiler setup jprofiler on linux
  • jquery IE AJAX issues
  • jquery spring AJAX
  • keyboard music java typing soothing notes auto suggest
  • liferay kids version
  • liferay web 2.0 java/j2ee
  • linux - the difference between hard and soft links
  • linux mysql
  • linux mysql setup quick start
  • Linux ssh autologin with putty
  • LINUX usefuls
  • linux)
  • LinuxPerformance Tuning(apache
  • log4j setup useful
  • lucene solr
  • mac m701 android skype not working crash
  • maven
  • maven cut reduce build time
  • microsoft ODBC oracle dll connection issues
  • Mobile Ad Services (adwhirl)
  • opsourcecloud
  • oracle connect by hierarchy
  • oracle table previlege
  • Oracle thin vs OCI(type II/thick) drivers
  • pdf 2 text
  • Pega PRPC
  • php
  • rackspacecloud
  • Rewrite rules in apache and IIS
  • scaffold
  • setting up a static ip on SKY broadband
  • setup quick start
  • Single Sign on - OpenSSO with Liferay
  • smart gwt
  • smtp email test mock server james
  • SMTP MAIL telnet windows
  • Software tools mind map freemind j2ee tools
  • Speed typing tips.
  • Spring + Hibernate Usefuls BaseDAOHibernate
  • Spring annotations with spring-mock not working 2.0 2.5.6
  • spring jndi datasource lookup
  • Spring portlet mvc and spring servlet mvc validation
  • Spyware trojan and virus removal tools
  • struts magic
  • SVN/ Subversion Tips and traps
  • tabbed ms dos console cygwin console
  • Texter - An auto text expander autotyper
  • Textpad tricks
  • The art of debugging
  • tomcat
  • Tomcat Exploded war - cut deployment time
  • Tomcat on linux tips
  • Tomcat on linux tips commands
  • TypeIt4Me
  • Typinator
  • Useful Eclipse Plugins
  • Useful Eclipse Plugins eclipse shortcuts keys
  • Useful tools
  • web content
  • xcode cocos2d iphone box2d
  • xpath xml xquery

Blog Archive

  • ►  2013 (19)
    • ►  August (17)
    • ►  July (1)
    • ►  January (1)
  • ►  2012 (7)
    • ►  August (1)
    • ►  June (4)
    • ►  April (2)
  • ▼  2011 (20)
    • ►  November (1)
    • ►  October (1)
    • ►  August (1)
    • ►  July (3)
    • ►  June (1)
    • ►  April (2)
    • ▼  March (4)
      • Gwt JSNI gotchas
      • Mock Mock Mock
      • Batch script to load developer environment
      • Smart GWT Gotchas
    • ►  February (1)
    • ►  January (6)
  • ►  2010 (27)
    • ►  December (3)
    • ►  July (2)
    • ►  May (3)
    • ►  April (2)
    • ►  March (5)
    • ►  February (10)
    • ►  January (2)
  • ►  2009 (32)
    • ►  December (5)
    • ►  November (2)
    • ►  September (3)
    • ►  August (6)
    • ►  June (4)
    • ►  May (4)
    • ►  April (3)
    • ►  March (2)
    • ►  February (3)
  • ►  2008 (28)
    • ►  December (1)
    • ►  October (2)
    • ►  September (2)
    • ►  August (4)
    • ►  July (7)
    • ►  June (1)
    • ►  April (2)
    • ►  March (2)
    • ►  February (2)
    • ►  January (5)
  • ►  2007 (24)
    • ►  December (3)
    • ►  November (2)
    • ►  October (6)
    • ►  September (1)
    • ►  August (3)
    • ►  July (8)
    • ►  June (1)
Powered by Blogger.

About Me

Unknown
View my complete profile