Archive Page 2

03
Nov

Automated Eclipse GUI testing the quick and simple way

We’re very test driven here at Cape Clear, we develop automated tests for everything we do. We’re not strict about writing our tests first, I for one write my tests with my code, iterating between one and the other in the course of realising a story (we follow Scrum, a lightweight wrapper process on agile/XP). I wouldn’t dream of writing code without some level of automated test coverage, to me it is meaningless - how do I know the feature code works if I don’t have something that proves it works now, and as I refactor the code base through iterations of the product? Writing tests makes me many orders of magnitude more productive as a developer. I still hear the “lack of time and resources to write automated tests” excuse from developers I know in other companies. Sometimes I argue with them, sometimes I just smile benignly: you don’t need more resources or time to write tests, writing tests gives you more resources and time, and of course results in far superior quality software. But the fly in the ointment for us has been automating the GUI testing of our Eclipse-based tools. We have extensive junit tests for the non-GUI parts of the tools, like our (WTP) facet install delegates, our builders, our models etc. Eighteen months ago we chose Eclipse TPTP, the GUI recorder and playback toolkit, to automate our GUI tests. Maybe others have had more success with TPTP than we have, but our experience was less than satisfactory. In the end we only achieved a tiny amount of coverage with it, and it is difficult to keep these kinds of tests passing and running continuously across multiple branches of the product. In general GUI recorder/playback tests are very brittle to even minor changes in the user interaction. Several things happened recently that made me realise we could and should drop that approach. We started to push our (PDE) junit tests up into the UI, specifically in relation to testing our GMF-based SOA Assembly Editor. We wrote tests that did things like clicking on all the tools in the palette and checking that the edit parts and model elements were created correctly. PDE junit tests run in the UI thread. It struck me that we already had 99% of what we needed to automate our GUI tests from junit. What we did not have was:

  • a test framework, test APIs, which read like a GUI test specification
  • the ability to automate the testing of blocking UI elements, namely wizards and dialogs

The first was easy, I took a couple of our WSDL-to-Java project wizard GUI test cases and prototyped the kind of APIs I wanted, they read just like we write our test specs. Then I implemented the APIs, most of which were very thin (but more test friendly) facades on existing APIs and existing test code. That left me with the wizards and dialog problem. When you launch an SWT wizard or dialog from a PDE junit test, it blocks because its waiting on input from the SWT event queue. The blocking happens in the open() method of org.eclipse.jface.window.Window, from which WizardDialog is derived. In an automated test, we want the input to come from the junit test code, not from the SWT event queue. Fortunatly, open() is public. I will resist going off on a tangent here about one of my pet gripes: the excessive marking of methods as private and classes as final etc. - let me decide how I want to specialise your code, you cannot see all ends and mostly I know what I’m doing. Anyway, back on topic, so now we have our own CcWizardDialog (which extends WizardDialog), and the code looks like this:

public int open() {
  if (this.cctest == null) {
    return super.open();
  }
  else {
    return doTestOpen();
  }
}
protected int doTestOpen() {
  Shell shell = getShell();
  if (shell == null || shell.isDisposed()) {
    shell = null;
    create();
  }
  shell = getShell();
  constrainShellSize();
  shell.open();
  ICcWizard ccWizard = new CcWizardImpl(getWizard(), this);
  cctest.testWizard(ccWizard);
  return getReturnCode();
}

The cctest member is an object that implements a simple callback interface, typically its the junit test itself. There is no difference in adding these kinds of test hooks to code and doing test-driven development. We write our code to be testable by code. Remember that we’re not trying to test SWT or core Eclipse platform components, we know they are well covered, stable, mature - basically: we know they work. And of course we do manually test and use our tools too. The ICcWizard interface looks like this:

public interface ICcWizard {
  ICcWizardPage getCurrentPage();
  ICcWizardPage next();
  ICcWizardPage back();
  void finish();
  void cancel();
  IWizard getWizard();
  boolean isNextEnabled();
  boolean isFinishEnabled();
}

And (an abbreviated) ICcWizardPage interface looks like this:

public interface ICcWizardPage {
  void setTextValue(...);
  void selectComboValue(...);
  void setCheckBox(...);
  void setRadioButton(...);
  ...
}

Now you can start to see how the junit test reads, just like you’d write a GUI test spec: launch the wizard, set a value in a text box, select a value in a combobox, go to the next page in the wizard, select a radio button, press finish. After which the call stack unwinds back to the junit test, which can then use project APIs to verify the results. I’ve been deliberately vague about ICcWizardPage. How that works is also quite interesting, and very simple. I will detail this and more in another posting. What I really like about the whole approach is that the tests are quick to write and simple to maintain.

01
Nov

The invisible shed

Rarely do I read something which really makes me laugh out loud: invisible shed.

15
Oct

Cape Clear links

Todays Cape Clear links:

04
Oct

Seeking experienced Eclipse tool developers

We’re looking for a couple of junior and senior Eclipse tool developers at Cape Clear, and we also have open Java server engineering positions. Check out our new SOA Assembly editor with Cape Clear 7.5, it could be you!

22
Aug

Impressed by GMF, but a hefty dose of patience is required

Over the last couple of months we’ve been developing (should I say “modeling”?) a GMF-based graphical editor to support the new assembly and multi-channel, multi-tenant mediation features of Cape Clear 7.5. Actually, I’ve had pretty much no hands on involvement with it myself, a colleague of mine championed its use and has become quite expert with it, but I thought I’d pass on some of our experience. We are using GMF 1.0.3 as we are shipping with Eclipse 3.2.2 (we plan to move to 3.3 later in the year). The promise of GMF is rapidly rolled graphical editors with lots of eye candy and neat features for free, achieved with near zero code, or at least approaching zero when compared with GEF-coded editors. Our BPEL editor is GEF-coded, so we have something very substantial to compare our Assembly Editor with. Generally, I am very impressed by GMF, but much patience is required to get the best out of it. See pretty picture (a high-res version is viewable here).

GMF coded editor

Our core model is described in XML Schema and we generate our EMF model from that. A few points then:

  • This is an excellent getting started presentation.
  • It can seem like there is a huge gap between an initially generated editor (based on your model/schema) and where you know it needs to be. There may well be, but it is not necessarily a code-gap. The temptation is to jump in and start extending and modifying generated code, patience is required to do the right thing. Doing the right thing means trawling through examples and forums, posting questions to newsgroups and waiting on answers.
  • Go back to your source schema, modify and constrain it appropriately to help get the end feature the way you want in the generated editor.
  • If you have a schema that contains a lot of similar things, start with a subset of the schema which contains just one example of all the distinct elements, and get a working editor for that. Then add back in the other stuff - which is hopefully just repetition. In other words, reduce the problem space to something manageable to start with.
  • Make one model change then re-generate. The error reporting in the generation process is not very clear and diagnosing one cause and effect at once is by far the easiest way to work. Read all the error information reported and watch for compilation errors in the generated code too.
  • Make small changes to the model, regenerate and test them. When you are happy, commit those distinct changes to source control. Move on to the next task.
  • Keep step-by-step instructions for regenerating your EMF and GMF models when your schema changes, there will probably be a few manual fix-ups required (e.g. GMF 1.x doesn’t merge plugin.xml changes - 2.0 does apparently)

GMF has made it possible for us to have a great graphical editor for our Assemblies in a timeframe we would not have been able to GEF-code one in - or at least, nothing this polished and (almost) ready to ship! Hats off to the folks behind it.

15
Aug

Social Network DaaS

Duane talking about social networks doing DaaS and some of the advantages it would have. But beyond social networks, the security and integrity of my data is key, like the stuff I have in my Google hosted spreadsheets or my Google hosted mail (uh, is it safe??). I want to be able to use my data with different services, I don’t want to have to enter my data into different services.

10
Aug

More facets please

I’m pleased to see that the plan for WTP 3.0 includes the intention to make the Faceted Project Framework more generally available to Eclipse projects and adopters. I may not be so pleased when I figure out the work we’re going to have to do here at Cape Clear to migrate to this, but hopefully it won’t be too painful! Our Web service projects are built on WTP and facets, and while not perfect, broadly speaking adopting the framework has been very positive and successful for us. For example, in Cape Clear 7.5 we’ve added a new Assembly Facet which allows our existing BPEL-based and Java-based web services to take on new behaviour, namely multi-channel, multi-tennant mediations. The facet framework made this really easy. I think I did the basic facet definitions, constraints, data model and install delegate in a few days, and voila! I was then able to add this facet to web service projects created with Cape Clear (Studio) 7. If the work to common-ise the Faceted Project Framework is completed successfully, hopefully we’ll see more adoption amongst Eclipse top level projects, there is one in particular I have in mind that could really benefit, but I won’t mention any names :-)

09
Jul

Solar powered WiFi

Soon there won’t be anywhere the radiation can’t get you. But at least when you’re being consumed by the brain tumors you can be happy it was green radiation that got you. I don’t think this is funny btw.

05
Jul

Michael Cote on Eclipse Europa

Michael Cote over at Redmonk has quite a good article on the Eclipse Europa release. Interesting in the light of my previous post that he talks about Eclipse developers starting to become a fully fledged category like Java developers and Microsoft developers. However, he does get some things very wrong, like describing Borland/Codegear as one of “the first to dive into the Eclipse platform”. They were so not one of the first, and they are now playing catch up. In contrast, Cape Clear was an early adopter, and the maturity of our tools reflects our considered and considerable investment in building on Eclipse. He mentions the ongoing battle between JSR 277 and OSGi, which Eclipse provides excellent tools for, being built on an OSGi core.

03
Jul

Is Eclipse plugin development experience a specialist skill?

Is Eclipse plugin development experience a specialist skill? I’ve been asking myself this question recently, as here at Cape Clear Software we are recruiting for a senior engineering position on the Eclipse-based (Jolt award winning) Cape Clear Studio team (based in Dublin, Ireland, if you’re interested). I first started learning Eclipse plugin development about four years ago, having been an Eclipse (Java) IDE user for some time before that. I made a deliberate decision to add this development feather to my cap, as I had always been interested in tool development and I saw Eclipse becoming the dominant platform for this. Coupled with that it is one of the most interesting and challenging development environments I’ve worked in. Four years ago there was very little in the way of documentation, articles or books on the platform, so the learning curve was quite steep. Today, things are considerably better, although part of the challenge is the requirement to understand a broad spectrum of APIs - frequently by stepping through their code in the debugger. And that is also part of the pleasure of working with the SDK, that you can step through the code! I think experience in Eclipse plugin development is particularly worthwhile to have. If you are a Java developer, probably already quite comfortable with JavaEE technologies, maybe you’ve done some rich-client work with Swing - IMO, Eclipse is a really super platform on which to broaden and deepen your development skills. Think of it this way, Eclipse is to enterprise tools, as Java, JavaEE and the myriad of Java-based technologies and open source components are to enterprise software in general. When I was in college I always wanted to work on development tools - I just loved Borlands Turbo Pascal and Turbo C products - but the opportunities were pretty much non-existent outside of certain geographical areas. Eclipse has changed that. Now - fifteen years later - I have that job.