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.
To content | To menu | To search
Sunday, December 20 2009
By Henri Tremblay on Sunday, December 20 2009, 22:45 - Java
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
By Henri Tremblay on Thursday, December 17 2009, 01:45 - Java
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:
Tuesday, December 15 2009
By Henri Tremblay on Tuesday, December 15 2009, 02:08 - Java
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:
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
By Henri Tremblay on Sunday, September 13 2009, 00:57 - Java
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.
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:
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:
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:
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.
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:
I would like to provide a set of helpers to make partial class mocking easier.
These seem to get popularity so it would be nice to be able to have matchers using this syntax.
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.
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?
By Henri Tremblay on Sunday, September 13 2009, 00:05 - Java
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
By Henri Tremblay on Thursday, August 27 2009, 23:59 - Java
Not really a super duper news but still... it's out. Especially because in fact, not much have changed.
There was also some internal cleanup but nothing that worth mentioning (even if it was time consuming...)
Wednesday, July 15 2009
By Henri Tremblay on Wednesday, July 15 2009, 21:59 - General
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.
Yes, the main site is in construction. We're working on that... remember, they're musician, not web designers.
By Henri Tremblay on Wednesday, July 15 2009, 20:00 - General
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
By Henri Tremblay on Sunday, June 21 2009, 17:13 - Java
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
By Henri Tremblay on Saturday, June 20 2009, 17:40 - Java
I hope most you have noticed EasyMock 2.5 version is finally out. For this version I had two goals:
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.
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.
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.
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
.
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.
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.
By Henri Tremblay on Saturday, June 20 2009, 17:18 - General
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?