Henri's Mind

To content | To menu | To search

Tuesday, November 15 2011

EasyMock 3.1 released!

EasyMock 3.1 was just released. It mainly contains fixes on long standing complex issues.

See the release notes are below.


Release Notes - EasyMock - Version 3.1

This release is mainly a bug fix release. It solves a series of long standing issues.

It is fully compatible with version 3.0 but capture methods of primitive types were deprecated and renamed to solve compilation issues. The deprecated methods will be removed from the next EasyMock version.


  • Bug
    • EASYMOCK-21 - finalize() should be treated specially
    • EASYMOCK-39 - Bridge methods are always mocked, regardless of partial mock
    • EASYMOCK-40 - Can't replay a mock on interface without cglib
    • EASYMOCK-43 - Update maven-javadoc-plugin to 2.7 (Maven build broken)
    • EASYMOCK-47 - samples.zip file is missing
    • EASYMOCK-89 - Memory leaks in EasyMock
    • EASYMOCK-90 - Partial mocking: Difficulties with covariant return types
    • EASYMOCK-100 - EasyMock not compiling with JDK 7 or Eclipse Helios or later
  • Improvement
    • EASYMOCK-44 - MockBuilder.addMockedMethod should fail for final methods
  • New Feature

Monday, November 1 2010

EasyMock: Facts and fallacies

I just published an article giving my thoughts about EasyMock and the comparisons going around. Especially with Mockito. Looking forward for your comments

Tuesday, May 11 2010

EasyMock 3 is out!

I'm really proud to announce that EasyMock 3 was released this week-end. It doesn't contain everything I was trying to push into but still has the main features.

The biggest is that the class extension is now deprecated. The normal EasyMock can now perform class mocking. This is something everyone was asking for for a while now. The migration should be painless. Just remove the ".classextension" part in your imports.

Full release notes are here

Enjoy!

Sunday, December 20 2009

EasyMock CE 2.5.2

This is the final planned version for EasyMock and EasyMock CE 2.

It contains an implementation of EasyMockSupport that allows class mocking.

Next step is EasyMock 3.

Thursday, December 17 2009

EasyMock CE 2.5.1

As promised, EasyMock CE 2.5.1 is out. It's the exact replication of the 2.5 version except it is under Apache 2.0 license.

The pom was also updated to use EasyMock 2.5.2, the latest version under Apache.

The roadmap:

  • EasyMock CE 2.5.2 containing EasyMockSupport for the class extension plus potentiel bugs. Probably out in a week
  • EasyMock 3

Tuesday, December 15 2009

EasyMock CE 2.5

I just delivered EasyMock CE 2.5 about five minutes ago. Helped from suggestions of many users, I think I've managed to build a clean and friendly API to create partial mocks. It's based on the builder pattern.

PartialMock mock = createMockBuilder(PartialMock.class)
    .addMethod("foo")
    .withConstructor(1, 2, 3)
    .createMock();

As you can see, pretty straightforward and no reflection required anymore.

The complete list of changes is here:

  • Incorrectly wrapped exception returned when EasyMock methods receive a parameter that is not a mock
  • Stub exception causes NPE (2407137)
  • Move to Subversion
  • Build entirely with Maven
  • Objenesis not embedded anymore
  • Add OSGi header to manifest (2774873)
  • New IMockBuilder interface to easily perform partial mocking (2822905, 2788098, 2783949)
  • Class mocks are now serializable (1963458)

I hope you will enjoy this new and long awaited version and I'm looking forward for any feedback.

The roadmap is now to deliver EasyMock 2.5.1 which will be under Apache 2.0 license. Then will come EasyMock 2.5.2 which will include EasyMockSupport for class extension.

After that EasyMock CE will be synchronized with EasyMock. Work on EasyMock 3 will then start.

Sunday, September 13 2009

EasyMock 3

I've been thinking about EasyMock 3 for a while now. I'm starting to know what I'll put in there. So it's time for a little post about my roadmap just to ask the world what there think about it.

Merge EasyMock and EasyMock Class Extension

Originally, it was thought that mocking classes was caused by bad design. Years have passed and we now know that there are reasons that justify class mocking. Mainly legacy code and base class testing (where the tested class has mocked methods).

Also, even if we tried to make it as painless as possible, it can be annoying to juggle with EasyMock and EasyMock CE imports. So I would like to merge the two projects. However, I also have some requirements:

  • Be able to desactivate class mocking using EasyMock properties
  • Be able to mock interfaces without having cglib in dependencies

Mock private, final and static methods (and final classes)

This requires class instrumentation. So it's not that easy to do. The two possibilities are to have dedicated test runners for the main test frameworks (JUnit and TestNG) or to have JVM class instrumentation. Requirements are:

  • It should be an add-on over EasyMock normal behavior and totally optional
  • No test framework should be in dependency. This probably means that there should be dedicated a project for each test frameworks.

Shorter tests

The new EasyMockSupport is a little bit about that. But it want to do more to reduce the code needed to use EasyMock. This might also require dedicated test runners. Requirement:

  • Be backward compatible with EasyMock 2

Get rid of EasyMock 1 code

Java 5 is now used pretty much everywhere so everyone can use EasyMock 2 now. To clean the code, I want to remove the compatibility with EasyMock 1.

Annotations

I'm not a big fan of it but sometimes it can be useful to have test annotations on your business code. For instance to create mocks on all dependencies of an object at once. The requirements are:

  • The business code should only have annotations in dependency. No EasyMock code
  • It should be flexible enough allow strict and nice mocks to be created
  • If possible, EasyMock should work without the annotation dependency

Easier partial class mocking

I would like to provide a set of helpers to make partial class mocking easier.

Hamcrest and assertThat kind of matcher

These seem to get popularity so it would be nice to be able to have matchers using this syntax.

Be able to mock equals, toString and hashCode

The default behavior is a good thing most of the time. However, Being able to mock these two methods can be useful once in a while. So I think we should be able to overload the default.

Conclusion

As you can see, it's a pretty big roadmap. So I don't think everything will make it in the first version. Merging projects and getting rid of EasyMock 1 will be a good start.

What do you think?

EasyMock 2.5.2

Just a quick post about EasyMock 2.5.2. It just went out. Mainly to fix a dumb bug on the capture but I also decided to include a new class named EasyMockSupport.

This class should be helpful to anyone who's tired of replaying and verifying explicitly all mocks. It's a helper keeping track of your mocks. Nothing revolutionary but I think it could be quite useful. Here's an example:

public class SupportTest extends EasyMockSupport {

    private Collaborator firstCollaborator;
    private Collaborator secondCollaborator;
    private ClassTested classUnderTest;

    @Before
    public void setup() {
        classUnderTest = new ClassTested();
    }

    @Test
    public void addDocument() {
        firstCollaborator = createMock(Collaborator.class);
        secondCollaborator = createMock(Collaborator.class);
        classUnderTest.addListener(firstCollaborator);
        classUnderTest.addListener(secondCollaborator);

        firstCollaborator.documentAdded("New Document");
        secondCollaborator.documentAdded("New Document");
        replayAll();
        classUnderTest.addDocument("New Document", new byte[0]);
        verifyAll();
    }
}

P.S.: Somebody know a good code formatter plugin for dotclear?

Thursday, August 27 2009

Objenesis 1.2 is out

Not really a super duper news but still... it's out. Especially because in fact, not much have changed.

  • The license is now Apache 2.0. This is mainly to allow EasyMock CE to have all its dependencies in Apache 2.0 and so be usable by more users
  • As requested, it's now an OSGi bundle (since I've mastered the way to test it by doing it for EasyMock)

There was also some internal cleanup but nothing that worth mentioning (even if it was time consuming...)

Wednesday, July 15 2009

Grand Life

While I'm talking about music, I'll do some publicity for a nice rock band from Montreal called Grand Life. My brother is the bassist. They are highly profesionnal and I love what they do. Tell me what you think. That are also looking for a manager in case you know someone.

MySpace
Site

Yes, the main site is in construction. We're working on that... remember, they're musician, not web designers.

Eric Lewis

I had the great chance to attend USI ealier this month (more on that later). One of the greatest surprises was an unexpected one in the name of Eric Lewis.

Last year, the final keynote was Neil Armstrong (yeah, the moon guy). So it was quite hard to top this year. They had the idea to change the beat a little and to ask the not yet famous jazzman Eric Lewis (aka ELEWW).

This guy is just amazing!

He's a pianist who tries to reproduce popular rock music on his instrument. It takes him loads of concentration and extreme stamina but the result is outstanding.

Apart from that, I had the chance to have a little chat with him and he's a really nice guy.

So, I think it worth this little post to do him some publicity. Here are some links:

MySpace
Wikipedia
Personnal site
Twitter

Go see him in live. That's where he's at his best.

Sunday, June 21 2009

EasyMock 2.5.1: When simple is not enough

EasyMock used to be under MIT license which seemed to be the simplest, freest and openest license there is. As per version 2.5.1, EasyMock is under Apache 2.0 license. BTW, versions 2.5 and 2.5.1 are identical except for the license.

Why do we changed?

It seems that the MIT license is in fact too open. It prevents some users to use EasyMock. Users with a law staff since us, naive engineers, are not aware MIT license put us under is such a threat.

In case you're interested, it's all about paragraph 3 of the Apache license.

3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.

It basically means (correct me if I'm wrong) that the license grant a patent usage right to anyone using EasyMock if EasyMock code was ever patented. Which basically prevents us from building a successful open-source framework, have it used, patent it and ask money from our users.

However, it also means that no users can start a patent litigation lawsuit over EasyMock (the Work) without loosing the right to use EasyMock. So it also protects the contributors against weasels.

Objenesis and EasyMock CE will also be moved to Apache license for the same reason.

Saturday, June 20 2009

EasyMock 2.5

I hope most you have noticed EasyMock 2.5 version is finally out. For this version I had two goals:

  • Learn from my mistakes that prevented some users to upgrade to 2.4
  • Implement a lots of great ideas that where submitted by you

You can have the complete release notes here (at the end. And yes, I should add anchors). However, I'll give some more details below.

Properties and thread-safety

EasyMock 2.4 had a feature called thread-safety check. Basically, it would return an error if the mock wasn't flagged as thread-safe and used in a multithreaded environment. The problem was that it was on by default. So someone with a lots of tests in a multithreaded environment will have them now failing. And he'll need to call makeThreadSafe() on all of them to repair.

The strange thing is that previously, EasyMock wasn't behaving really well in a threaded environments. So I would have expect these tests to have random failures anyway. But it seems I was wrong.

So I did two things. First, I've changed the default behavior. Mocks are now thread-safe by default and there's no thread-safety check. Then, if you don't like this default, you can use the new property system to change that. Hopefully, that should cover it all.

Capture

In EasyMock 2.4, the capture was having a very hard to guess behavior and was quite limited in capture types.

EasyMock 2.5 changed that. You should see the behavior everyone expect. A method is called, the parameter is captured. You can also decide to capture the first, the last or all parameters.

andDelegateTo

That was a neat idea (from virtualwarp). It allows to have something more typed than andAnswer. The drawback being that you have to implement an interface.

As a unexpected side effect, you can use this to create a Real objects spy.

Error messages

On the Yahoo group, we keep receiving questions about why a given example is failing. Big sign that the error messages were not that clear. One of the worst was the +1 on an unexpected call. I've worked on it (with Tammo insights) to improve some and to refine some others. For instance the unexpected call message now depends on the number of possibles matches to have a more meaningful message.

OSGi

The great thing when you're working on a framework like EasyMock is that people are asking you things about stuff you don't know. For instance, I never had the time to use an OSGi framework. Banks still love classic application servers. However, I always thought that OSGi seemed like a good idea to improve development times. Application servers take ages to launch and deploy.

But someone asked me to have EasyMock being an OSGi bundle. So I was forced to learn. After some reading (mainly the official specification), I managed to get started.

The maven-bundle-plugin and Spring OSGi test framework did the rest. This is interesting enough to worth its own post.

EasyMock 2.5 is now an OSGi bundle.

First post

Welcome to my new blog. If everything goes well, I should talk about IT and life in general. Some posts will be in French, some in English. I'll try to do most of the IT ones in English.

Let's see how it goes!

P.S.: I wondering what you think about the blog look. I think it's quite clear and neat. Do you?