stackoverflowmailer / atunit

Automatically exported from code.google.com/p/atunit
Apache License 2.0
0 stars 0 forks source link

Support for easymock class extensions? #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This is a great tool!
Do you have any plans to support the 'classextension' EasyMock framework?

Original issue reported on code.google.com by alison.r...@gmail.com on 22 Nov 2007 at 9:51

GoogleCodeExporter commented 9 years ago
I've considered supporting Class Extension and JMock's ClassImposteriser, but 
haven't
given any thought to what that would look like.

There's also the question of whether it should be done.  One of the AtUnit's
objectives is to provide some structure and guidance to test authors, and the 
need to
mock a class has always been to me an indicator that an interface is missing and
should be added.

Original comment by logan.jo...@gmail.com on 24 Nov 2007 at 4:06

GoogleCodeExporter commented 9 years ago
Sure, that is a fair point.

Original comment by alison.r...@gmail.com on 26 Nov 2007 at 2:51

GoogleCodeExporter commented 9 years ago
I understand the concern, but I don't agree with your reasoning. Often you find 
yourself working with third party, closed source API's that don't always have 
the 
best design possible. Because they can not be modified, you need something like 
EasyMock's class extension to mock them.

For example, you could also make it harder to mock classes:
@Inject @ClassMock(I.KnowWhatImDoing) Blah blah;

You can probably do better, but you get the point. I think you should include 
support for mocking concrete classes.

Original comment by robbie.v...@gmail.com on 5 Jan 2008 at 5:10

GoogleCodeExporter commented 9 years ago
I'm familiar with that argument, but how often does that happen, really?  I may 
have
lucked out, but I can count on one hand the number of times I've wanted to use a
third-party library that didn't provide interfaces, and each time I just 
defined an
interface of my own and implemented a thin adapter.

When you keep bad design at arm's length in this way, which to me seems the
appropriate thing to do, what do you need class mocks for?

Original comment by logan.jo...@gmail.com on 5 Jan 2008 at 7:10

GoogleCodeExporter commented 9 years ago
+1 for adding class mocking

Original comment by gk5...@gmail.com on 4 Sep 2008 at 8:00

GoogleCodeExporter commented 9 years ago
+1 for class mocking

Original comment by mike.a...@gmail.com on 28 Nov 2008 at 3:39

GoogleCodeExporter commented 9 years ago
If you want to mock a class with AtUnit just do the following...

@Inject @Unit Something something;

@Inject SolidClass myClassObject;

public void configure(Binder b){
  b.bind(SolidClass.class).toInstance(createMock(SolidClass.class));
}

Original comment by Tristan....@gmail.com on 19 Dec 2009 at 8:44

GoogleCodeExporter commented 9 years ago
EasyMock 3.0 has integrated class mocking into the EasyMock core, deprecating 
the EasyMock class extension.  That may eliminate the need for special support 
of the class extension entirely.

Original comment by da...@carrclan.us on 6 Jan 2011 at 7:49