Where he blogs about his eclipse musings
eclipse
Eclipsetasy! Time to throw away the dope…
Jun 19th
… and move to newer dope…
I just realized that I had about 58 eclipse SDKs downloaded on my hard drive and 22 instances of different versions of eclipse. That was a whooping 9GB for the sdk downloads and 6.5GB for the extracted versions. Time to move to newer dope
Similar was the case on the cruise based build grid that tested SWTBot from all versions starting from eclipse 3.2 upwards to the latest RC build on all platforms — linux-gtk/linux-gtk-64/win32/macosx-carbon.
Announcing a new release of SWTBot
May 29th
You can download the latest and greatest from the SWTBot download page.
A listing of some of the new features available:
Bug 263036 – SWTBot finally has an icon that was missing since two years!
Bug 269919 – Added support for toggle buttons
Bug 271246 – Better support for handling editors. This should serve as a good start towards providing support for multipage, forms based editors
Bug 271132 – Using Display#post() to support sending native click events instead of fake events. This is still work in progress and not all widgets support native events yet.
Bug 273624 – Use native keyboard events for typing. SWTBot currently defaults to using AWT robot. SWT’s Dispay#post() is available as well — it is however buggy across platforms and swt versions. Since SWTBot uses native keyboard events, it needs to understand various Keyboard Layouts.
Bug 267189 – Support capturing screenshots of widgets.
Bug 277093 – Support for Link widgets.
There are also a lot of minor bugs that were fixed in this release.
Java and Unicode monday morning blues
May 25th
Monday morning excitement. JUnit tests that pass in the IDE fail in ant and cruise servers running on all platforms.
java.lang.AssertionError:
Expected: a string containing "... text=Ç..."
got: "... text=Å..."
My immediate reaction was the encoding used by the JVM. Setting the “file.encoding” system property to UTF-8 did not help. Running the ant based tests in remote debugging mode also confirmed that the two strings were indeed different.
Since the tests used Cobertura for code coverage, the next step was to disable cobertura. Cobertura manipulates the generated byte code to add logging statements for code coverage. Still the same error.
The hidden gem seemed to be the -encoding java compiler flag. Setting it to UTF-8 fixed the problem.
So the next time you have something fail because of an encoding issue, it could just be the compiler encoding and not just the encoding used in the runtime!
Hitler Does Agile — Are You ?
Feb 20th
Via this link which David pasted on IRC
Hitler doing agile with very few unit tests + no nightly build = no safetynet.
Unfortunately this is quite representative of how a lot of eclipse projects work (ducks to take cover).
Are you builds running in the same way ? Do you write tests before you write code or test manually ? Do you run all the tests before you check in ? Do you have <a href="any CI server to run your builds on a variety of platforms that you support ? Do your unit tests have enough of code coverage to give you the confidence to refactor ? Is your build reproducible on any machine (in less than 5 manual steps) ?
If you’re answering no to any of the above, then this video is for you:
SWTBot has moved to eclipse.org!
Dec 3rd
SWTBot has finally moved to eclipse.org.
There is a bit of documentation sitting at the old home that needs to move to eclipse.org. I’m hoping to move this over in the next couple of days.
The sourcecode will also move during the course of the week. I’m busy renaming plugin IDs and packages to use the org.eclipse.swtbot namespace. Meanwhile you can participate on the newsgroups.
Cheers!
SWTBot Proposal at Eclipse.org
Sep 6th
SWTBot 1.2.0 released
Aug 30th
For the impatient:
Direct download link: https://sourceforge.net/project/showfiles.php?group_id=188411&package_id=220519&release_id=622752
Update site: http://swtbot.sourceforge.net/latest/update-site/
SWTBot 1.2.0 is the 3rd of the 1.x releases of SWTBot was released last night, and there have already been about 200 downloads by the time of writing this blog post.
SWTBot has always believed in release early release often mantra, and pushes out nightly builds out of CruiseControl. From the download stats I’m looking at, there are more downloads of the nightly build than the ’stable’ available on the sourceforge mirrors.
The highlight of the release is support for view menus and view toolbar.
Thanks to the contributors and adoptors, for patches, criticism, and suggestions for improvement. The release has fixed about 42 issues.
Read more on the detailed release notes and the changelog.
Copying code snippets for your blog
Jul 19th
There was a conversation on IRC a while ago about wordpress plugins for syntax-highlighting code snippets. Wouldn’t it be cool if you could copy code from eclipse and paste it into your blog ?
CodeSnippet for Eclipse lets you do just that:
protected void tearDown() throws Exception {
closeWindow("Create a new account");
closeWindow("Address Details");
}
Reusing Functional Tests – Part 1
Jun 21st
While writing some tests for SWTBot, there was quite some code duplication that could be removed by using some simple test patterns. This is part of a series of articles about how test code could be written better. This example uses SWTBot as a driver to drive an Eclipse application used by ACME Corporation.
Here is a snippet of a Test Case that creates an account in ACME Corporation’s customer management system.
public void testCreatesAccount() throws Exception {
bot.menu("Accounts").menu("New").click();
// nice wizard
bot.shell("Create a new account").activate();
bot.textWithLabel("Name:").setText("Will Coyote");
bot.textWithLabel("Email:").setText("will@coyote");
bot.button("Next>").click();
// yet another wizard
bot.shell("Address Details").activate();
bot.textWithLabel("Mailing Address:").setText("Will Coyote, middle of, nowhere");
bot.button("Finish").click();
assertThatAccountIsCreated("Will Cooyte", "will@coyote.com");
}
That’s a great start to begin writing tests. But there’s the problem: What happens if the test fails somewhere and the “Create a new account” or the “Address Details” window remains open ? This means that the rest of the tests fail or do not run at all. Not a problem, tearDown() to the rescue:
protected void tearDown() throws Exception {
closeWindow("Create a new account");
closeWindow("Address Details");
}
private void closeWindow(String windowTitle) throws Exception {
try {
bot.shell(windowTitle).close();
} catch (WidgetNotFoundException e) {
// do nothing if the window is not found
}
}
Now we write a test that tests if you’re able to create two users with the same name.
public void testShouldNotCreateTwoAccountsWithTheSameName() throws Exception {
bot.menu("Accounts").menu("New").click();
// nice wizard
bot.shell("Create a new account").activate();
bot.textWithLabel("Name:").setText("Will Coyote");
bot.textWithLabel("Email:").setText("will@coyote");
bot.button("Next>").click();
// yet another wizard
bot.shell("Address Details").activate();
bot.textWithLabel("Mailing Address:").setText("Will Coyote, middle of, nowhere");
bot.button("Finish").click();
assertThatAccountIsCreated("Will Cooyte", "will@coyote.com");
bot.menu("Accounts").menu("New").click();
// nice wizard
bot.shell("Create a new account").activate();
bot.textWithLabel("Name:").setText("Will Coyote");
bot.textWithLabel("Email:").setText("will@coyote");
bot.button("Next>").click();
// yet another wizard
bot.shell("Address Details").activate();
bot.textWithLabel("Mailing Address:").setText("Will Coyote, middle of, nowhere");
bot.button("Finish").click();
assertThatAccountIsNotCreated("Will Cooyte", "will@coyote.com");
}
Duplication, not a big deal, some bit of refactoring and you get to this. This also reduces the number of places where you’ll need to fix the test, if the label on one of the screens change.
public void testCreatesAccount() throws Exception {
createAccount("Will Coyote", "will@coyote", "Will Coyote, middle of, nowhere");
assertThatAccountIsCreated("Will Cooyte", "will@coyote.com");
}
public void testShouldNotCreateTwoAccountsWithTheSameName() throws Exception {
createAccount("Will Coyote", "will@coyote", "Will Coyote, middle of, nowhere");
assertThatAccountIsCreated("Will Cooyte", "will@coyote.com");
createAccount("Will Coyote", "will@coyote", "Will Coyote, middle of, nowhere");
assertThatAccountIsNotCreated("Will Cooyte", "will@coyote.com");
}
private void createAccount(String name, String email, String snailMail) throws WidgetNotFoundException, TimeoutException {
bot.menu("Accounts").menu("New").click();
// nice wizard
bot.shell("Create a new account").activate();
bot.textWithLabel("Name:").setText(name);
bot.textWithLabel("Email:").setText(email);
bot.button("Next>").click();
// yet another wizard
bot.shell("Address Details").activate();
bot.textWithLabel("Mailing Address:").setText(snailMail);
bot.button("Finish").click();
}
In the next article, you’ll get to see how you can reuse code better by using Screen Objects
Announcing SWTBot 1.0
May 22nd
I just made new release of SWTBot – 1.0
Direct download link: http://sourceforge.net/project/showfiles.php?group_id=188411&package_id=220519&release_id=601136
Update site: http://swtbot.sourceforge.net/latest/update-site/
Some features:
- A recorder API — now you can record SWTBot scripts. Still in beta though.
- Better SWTBot integration in eclipse — now you can run tests within eclipse.
- More API — now you can use more SWT controls using an even richer API.
- More stable than before.
For more details, you can read up on the release notes here.
