Eclipse Yoxos Services Downloads Blogs About
Home > Blogs >

Posts Tagged ‘Open Source’

on Sep 19th, 2011Effective Mockito Part 1

Last week I talked to a fellow developer, Frank Appel, about Mockito. We’ve been using this mocking library for over a year. We both agreed that of all the innovations we’ve tried in the last year or so, Mockito has boosted our coding productivity the most. With this blog series we want to share our experiences with Mockito. You see that I used the word “effective” in the title, and, in this context I want to define “effective” as arriving at clean test and production code as fast as possible.

To understand these posts you need to have a basic understanding of what mocking is. I recommend reading Martin Fowlers article,”Mocks aren’t Stubs“. You’ll also need some practice with Mockito. But, since you found this blog, you probably searched for the term Mockito icon wink Effective Mockito Part 1 , so this should be a given. Anyway, there is a third thing, that only affects this first post. You need to use Eclipse as your IDE. This post shows you how to setup Mockito in your IDE for the daily work. If you are using another IDE and you know how to achieve what I have described here, please share your tips in a comment. The follow up posts will not require Eclipse because they will be more Mockito specific. Enough prerequisites, let’s start with with the first thing that will boost your Mockito experience.

I always write tests first. My goal is to come up with a first test method really quickly to be able to create all the classes that I need by resolving the compiler errors using Eclipse’s quick fix functionality (CTRL/CMD+1 is your friend). What would be ideal, is to create a test class and just write the test without importing all the other stuff.  The Mockito and Junit stuff should automatically appear in my content assist. When using Mockito, I want to create a test method, write “mo”, open the content assist and it should show me all the “mock” methods.

I’ll give you an example to make this clearer and to show how to achieve this. If I write a test method and open the content assist (which I use all the time), the standard selection options are very basic.

Screen Shot 2011 09 12 at 8.37.40 AM Effective Mockito Part 1As you can see there are no “mock” methods but at least the Mockito classes. The reason is that the content assist only shows methods that are imported in the current class. So, by static importing Mockito this can be fixed.

Screen Shot 2011 09 12 at 8.38.31 AM Effective Mockito Part 1But this is not what I want. This assumes that I have to import all Mockito stuff manually, or that I need to write “Mockito” and organize my imports automatically. I really want to be able to just write “mo” and get a pre-filled content assist. Luckily there is an option that lets us achieve this. In Eclpse it’s called “content assist favorites”. It can be configured within your preferences. Let’s take a look at our favorites.

Screen Shot 2011 09 12 at 8.41.16 AM Effective Mockito Part 1As you can see, I added Mockito.*, Matchers.* and Assert.* to my favorites. This enables my content assist to show the available methods and import them when I’m using one. You may think, “hey, this will fill my content assist with unnecessary stuff when I’m writing production code.” But this is not the case. These imports are only available when Mockito and JUnit is on your build class path. So, by separating test and production code you only have these imports available in your test projects. Let’s take a look at the result.

Screen Shot 2011 09 12 at 8.41.29 AM Effective Mockito Part 1As you can see I haven’t imported any Mockito stuff yet but I can select all the mock methods from my content assist. This enables me to write tests really quickly because I don’t have to think about setting up a test, I can just write it.

This is just a simple trick to come up to speed as quickly as possible when writing tests using Mockito. In the next posts I will focus more on the Mockito specifics. I hope you liked it and will stay tuned icon wink Effective Mockito Part 1

followme Effective Mockito Part 1

Read the other Effective Mockito posts:

on Aug 20th, 2009Open Source Development Metrics

cats love linux 150x150 Open Source Development Metrics

The Linux Foundation just published a report with metrics about who and how much is contributing to the Linux kernel. As an Eclipse committer I found this insight into the kernel ecosystem fascinating. Below are couple of data points that got my interest.

Comparing kernel development over the last year (release 2.6.30 with 2.6.22):

  • development speed is increasing (patches per release: 50-100% up, lines of change per day: 100% up to 20,000 from 10,000 a year ago)
  • kernel size is increasing (+35%, 11.5m LOC vs 8.5m)
  • number developers  going up (+32%, 1,150 vs 870)
  • number of involved companies going up (+33%, 240 vs 180)
  • constant release rhythm of about 12 weeks/release – despite the increases
  • focus on commerial development (74,2% done by paid contributors, 18,2 % by non-paid contributors, 7,6% unknown)

Two things that impressed me:

  • the ability to keep release speed constant, despite a huge increase in contributors, patches and lines of code changed
  • the amount of diversity within the kernel community. The overall top-10 contributors (page 11)  amount to 66.7%.  As of today the 2009-top-10 contributors by LOC at Eclipse.org amount to 92,09%  (dash). So it looks like the weight of the kernel development is better distributed. Note, these are only 2009-YTD contributions.

What did you find interesting or impressive?

on Jul 28th, 2009Teamwork, Innovation and Diversity

I was really impressed with this article from today’s NY Times:

Netflix Competitors Learn the Power of Teamwork

I was particularly fond of this quote:

The biggest lesson learned, according to members of the two top teams, was the power of collaboration. It was not a single insight, algorithm or concept that allowed both teams to surpass the goal … Instead, they say, the formula for success was to bring together people with complementary skills and combine different methods of problem-solving

I think it provides an excellent example of the benefits received due to open collaboration (with distributed, diverse teams). Furthermore, I think it identifies a powerful and sustainable value creation and commercialization approach for open source projects.

What do you think? I think Eclipse does some of this already, but how can we improve things?

on Jul 13th, 2009Innovation, Competition and Open Source

There is an interesting op-ed in today’s NY Times from the venerable Robert Cringley:

Chrome vs. Bing vs. You and Me

Cringley implicitly asserts that neither Google nor Microsoft are going to innovate in the interest of You and Me and sadly, I think this is all-to-often true in ‘big-time, big-money’ corporate software.

First and formost, companies are interested to achieve ever higher ROI for their shareholders. This does not necessarily mean that they will build anything of value for You and Me.   They may innovate and that’s terrific when it happens. However, if they can make more money by attacking each other and protecting their existing turf… I think it’s pretty clear they will frequently do so.

In my view, this points directly at a long-term sustainable role for open source and startup ecosystems:  end-user-focused innovation.  Of course, as Bjorn Freeman-Benson points out, end-user focus can be a challenge for open source communities.

What’s your opinion?

on Mar 30th, 2009Open Source Strategy Summit at EclipseCon

The Eclipse Foundation organized an Open Source Strategy Summit in conjunction with EclipseCon, only open to member companies.

The day was packed with interesting presentations on Open Source Business models, Licensing, Open Source case studies and an outstanding presentation by Forrester analyst Jeffrey Hammond. His presentation was on Open Source adoption and his research is very encouraging for the Eclipse community and our EclipseSource offerings. Security, Maintenance and support are key issues when it comes to Open Source adoption, that is exactly what we offer for core Eclipse technologies like Equinox, RCP or RAP. He was comparing the Eclipse community to a shopping mall for customers with anker stores (big players) and boutique stores that together make a very compelling offering. Integration is key as enabler for a best of breed approach. I can really recommend his research on this topic. As an attendee of the summit I am one of the lucky guys getting this slides …

The little presentation on moving RAP to Open Source that I gave is public to everyone and is talking about some of the challenges working in the open – specifically in the context of Eclipse. You can view it online just below.

If you are looking for values of an Eclipse membership – this is the kind of event you should attend next time. We have been already discussing briefly about having an Open Source Strategy Summit at Eclipse Summit in Ludwigsburg this fall. I will sign up for this as soon as it will get announced.

Update: A slightly abriged version of Jeffrey Hammands slides are available from the Open Source Strategy agenda page.

© EclipseSource 2008 - 2011