Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Unable to fully utilize EasyMock. Not compliance with Test Driven Approach.

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

Recently in one of my projects, I started using EasyMock framework for mocking the objects. I'm not using EasyMock extensions, so I'm currently not able to mock static or private methods. Well I'm not complaining about it now, as I knew I need to use EasyMock extension. But the way I'm mocking the objects seem to be stupid to me and clearly it does not follow Test Driven approach. Please guide me on proper usage of the EasyMock or other better framework.

Currently, I'm mocking every step of execution (including the sequence of execution) using EasyMock based on the actual implementation of the class under test. This seems so wrong to me. If I had to change the sequence of execution, but keeping the net outcome as same, still I need to change my tests. I knew that I'm doing something wrong here.

For eg,



As you see, execute() method of ClassA, is invoking execute() methods of classB, classC, ClassD and some more processing, independent of these executes. Also, the sequence of execution also does not really matter. If I need to test execute() of A, I can mock B, C,D and write something like

EasyMock.expect(b.execute()).andReturn()
EasyMock.expect(c.execute()).andReturn()
EasyMock.expect(d.execute()).andReturn()

But what I'm currently doing here is I need to execute these steps in the same sequence they are being executed in actual class. The worst is, I need to do the same even for other processing that goes in parallel.

This is apparently not a test driven approach and rather I would call it as code driven testing. So I wanted to know, if this is a limitation of EasyMock or a limitation of my knowledge in EasyMock. If it is really a limitation with EasyMock, then is there any better framework I can use, where I can create all mocks objects and methods upfront and do not bother about placing them in exact sequence.

Can a good pointer for examples be provided for EasyMock or for other such frameworks?

Thanks



 
You learn how to close your eyes and tell yourself "this just isn't really happening to me." Tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic