<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jmhofer&#039;s insignificant insights &#187; Eclipse</title>
	<atom:link href="http://jmhofer.johoop.de/?tag=eclipse&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://jmhofer.johoop.de</link>
	<description>Coding from the perspective of a mediocre programmer</description>
	<lastBuildDate>Sun, 13 Jan 2013 18:29:22 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Four reasons why SWTBot doesn&#8217;t work out (for me)</title>
		<link>http://jmhofer.johoop.de/?p=185&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=four-reasons-why-swtbot-doesnt-work-out-for-me</link>
		<comments>http://jmhofer.johoop.de/?p=185#comments</comments>
		<pubDate>Wed, 25 May 2011 20:02:03 +0000</pubDate>
		<dc:creator>jmhofer</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Scala]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[RCP]]></category>
		<category><![CDATA[SWTBot]]></category>

		<guid isPermaLink="false">http://jmhofer.johoop.de/?p=185</guid>
		<description><![CDATA[After my little blog series about Jubula, I thought I&#8217;d try out something similar using SWTBot. However, there&#8217;s no use in writing the same tutorial again for the RCP mail application because it&#8217;s already there&#8230; Nevertheless, I attempted to implement the same few tests I wrote for Jubula, and you can view the results in [...]]]></description>
				<content:encoded><![CDATA[<p>After my little <a title="my Jubula blogs" href="http://jmhofer.johoop.de/?p=97">blog series about Jubula</a>, I thought I&#8217;d try out something similar using <a title="SWTBot" href="http://eclipse.org/swtbot/" target="_blank">SWTBot</a>. However, there&#8217;s no use in writing the same tutorial again for the RCP mail application because it&#8217;s already <a title="SWTBot Mail App Tutorial" href="http://swtbot.com/user-guide/running-swtbot-tests.html" target="_blank">there</a>&#8230;</p>
<p>Nevertheless, I attempted to implement the same few tests I wrote for Jubula, and you can view the results in the piece of code below:</p>
<pre class="brush: java">package de.johoop;

import static org.junit.Assert.*;

import org.eclipse.jface.bindings.keys.KeyStroke;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
import org.junit.Before;
import org.junit.Test;

public class FirstSwtBotTest {

  private SWTWorkbenchBot bot;

  @Before
  public void setUp() throws Exception {
    bot = new SWTWorkbenchBot();
  }

  @Test
  public void mailToolbarButtonShouldOpenMessageDialog()
      throws Exception {

    bot.toolbarButton(1).click();
    assertThatCorrectDialogIsDisplayed();
  }

  @Test
  public void openMessageMenuEntryShouldOpenMessageDialog()
      throws Exception {

    bot.menu("Open Message").click();
    assertThatCorrectDialogIsDisplayed();
  }

  @Test
  public void keyboardShortcutShouldOpenMessageDialog()
      throws Exception {

    SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
    bot.activeShell().pressShortcut(
        Keystrokes.CTRL, KeyStroke.getInstance("3"));
    assertThatCorrectDialogIsDisplayed();
  }

  private void assertThatCorrectDialogIsDisplayed() {
    final SWTBotShell openDialog = bot.activeShell();
    assertEquals("Open", openDialog.getText());
    assertTrue(bot.label("Open Message Dialog!").isVisible());

    bot.button("OK").click();
    assertFalse(openDialog.isOpen());
  }
}</pre>
<p>It&#8217;s a set of three tests opening the &#8220;Open Message&#8221; dialog via toolbar button, keyboard shortcut or menu entry. Simple.</p>
<p>At first glance, this looks neat, especially if you&#8217;re a developer: few lines of code, all directly in Java, using the already familiar <a title="JUnit" href="http://junit.org" target="_blank">JUnit</a> framework, well supported from within the Eclipse IDE.</p>
<p>Nevertheless, here&#8217;s my list of things I don&#8217;t like about this:</p>
<ol>
<li>Let&#8217;s begin with a minor nitpick: I&#8217;m using a German keyboard layout, and SWTBot complains that it can&#8217;t find my layout. This means that I either have to somehow create one (which might be easy, I haven&#8217;t checked), or I have to set my keyboard layout to the US one (it doesn&#8217;t matter for my simple <code>Ctrl-3</code> test).</li>
<li>Next, I can&#8217;t write these tests in <a title="Scala" href="http://scala-lang.org/" target="_blank">Scala</a> for some reason (I&#8217;d really like to use Scala for my tests, so very much more concise): In Scala, the following line:
<pre class="brush: scala">new SWTWorkbenchBot().toolbarButton(1).click()</pre>
<p>fails with a compile error in Eclipse: &#8220;Access to protected method <code>click</code> not permitted because enclosing class object <code>ScalaUser</code> is not a subclass of class <code>AbstractSWTBot</code> in package <code>widgets</code> where target is defined&#8221;. &#8211; What&#8217;s that?</p>
<p>If you ask me, it&#8217;s somehow caused by the <code>SWTBotToolbarButton</code> having an abstract public method <code>click()</code> returning an <code>SWTBotToolbarButton</code>, and inheriting from <code>AbstractSWTBot&lt;T&gt;</code>, which has an abstract protected method <code>click()</code> returning an <code>AbstractSWTBot&lt;T&gt;</code>.</li>
<li>Also, I don&#8217;t want to use JUnit for system tests. JUnit is a great framework if all you do is unit tests. If you&#8217;re testing on the level of integration or system tests, however, <a title="TestNG" href="http://testng.org" target="_blank">TestNG</a> is a way better fit if you ask me. The execution model of TestNG is a lot more flexible than that of JUnit (even if you use decorators and stuff there). For example, have a look at the data providers of TestNG. Unfortunately, there&#8217;s no TestNG integration for SWTBot.</li>
<li>Finally, here&#8217;s what I&#8217;d call a showstopper. Have you noticed how I say <code>toolbarButton(1)</code> in my code instead of the <code>toolbarButtonWithTooltip("Open Message")</code> you&#8217;d probably expect? That&#8217;s because using the latter method will require another dependency in your plug-in project. That dependency will have to get injected into your test object, too (the RCP mail application in my case). And unfortunately, it will add toolbar buttons and keyboard shortcuts to your test object!
<p>In my case, this leads to <code>Ctrl-3</code> suddenly not working as expected anymore: The tests have changed the behaviour of the test object! I absolutely can&#8217;t have that happening.</li>
</ol>
<p>For me, these four reasons unfortunately mean that SWTBot is not a viable tool for automating UI tests. I would really like to use it, especially combined with Scala, for quick and easy developer UI testing; I&#8217;d be quite happy if you could refute any of my four reasons above.</p>
<p>I&#8217;ve still got hope that maybe I&#8217;m just too stupid to use SWTBot correctly.</p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Four+reasons+why+SWTBot+doesn%E2%80%99t+work+out+%28for+me%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D185" title="Post to Twitter"><img class="nothumb" src="http://jmhofer.johoop.de/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=Four+reasons+why+SWTBot+doesn%E2%80%99t+work+out+%28for+me%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D185" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://jmhofer.johoop.de/?feed=rss2&#038;p=185</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>UI Testing with Eclipse Jubula: Executing the Tests (3)</title>
		<link>http://jmhofer.johoop.de/?p=163&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ui-testing-with-eclipse-jubula-executing-the-tests-3</link>
		<comments>http://jmhofer.johoop.de/?p=163#comments</comments>
		<pubDate>Tue, 17 May 2011 19:14:12 +0000</pubDate>
		<dc:creator>jmhofer</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Jubula]]></category>
		<category><![CDATA[RCP]]></category>

		<guid isPermaLink="false">http://jmhofer.johoop.de/?p=163</guid>
		<description><![CDATA[In my last blog post, everything was pure theory (if you&#8217;re looking for the start of the Jubula series, look here): I specified a few tests, but there&#8217;s no connection yet to any real application under test. Let&#8217;s rectify this! Before starting up Jubula today, look for the &#8220;AUT Agent&#8221; service and start it. The [...]]]></description>
				<content:encoded><![CDATA[<p>In my <a title="UI Testing with Eclipse Jubula: Specifying the Tests (2)" href="http://jmhofer.johoop.de/?p=132">last blog post</a>, everything was pure theory (if you&#8217;re looking for the start of the Jubula series, <a title="UI Testing with Eclipse Jubula: Preparing the Test Object (1)" href="http://jmhofer.johoop.de/?p=97">look here</a>): I specified a few tests, but there&#8217;s no connection yet to any real application under test. Let&#8217;s rectify this!</p>
<p>Before starting up Jubula today, look for the &#8220;<strong>AUT Agent</strong>&#8221; service and start it. The AUT Agent is our connection to the &#8220;real world&#8221;. It takes commands from Jubula and executes them on the application under test (you can even run Jubula and the agent on different boxes for distributed testing). On Windows, you might have to start the agent via &#8220;Run as Administrator&#8221;.</p>
<p>Next, start Jubula and open your project. Now, look for the &#8220;Connect to AUT Agent&#8221; toolbar button and press it in order to establish the connection to the agent we started before:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/23-aut-agent-button.png"><img class="aligncenter size-full wp-image-164" title="23-aut-agent-button" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/23-aut-agent-button.png" alt="" width="377" height="106" /></a></p>
<p>Next, start the test object via the &#8220;Start AUT&#8221; toolbar button. You should then see its ID listed in the &#8220;Running AUTs&#8221; view:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/24-run-aut-button3.png"><img class="aligncenter size-full wp-image-169" title="24-run-aut--button" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/24-run-aut-button3.png" alt="Running the application under test" width="365" height="161" /></a></p>
<p>The application under test is running now, and you can view it on your screen. However, we still can&#8217;t run any tests, as the logical components we specified last time are not yet mapped to their real component counterparts within the RPC application. Let&#8217;s fix this by starting the &#8220;Object Mapping Mode&#8221;, again from the toolbar:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/25-start-object-mapping.png"><img class="aligncenter size-full wp-image-170" title="25-start-object-mapping" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/25-start-object-mapping.png" alt="Starting the Object Mapping" width="255" height="120" /></a></p>
<p>Now activate the test object and move the mouse around within it. Notice the green borders around the various components? That&#8217;s the Jubula Object Mapper showing you the components it has detected. In order to add any of these to your object mapping, you have to press <code>Ctrl-Shift-Q</code>.</p>
<p>You can collect all components at once like that if you want to, but I&#8217;d advice against it because it can get crowded and confusing quickly in Jubula when you do that. Instead, start with the few components we currently require for our tests to run. In my case, this would mean capturing the mail icon in the toolbar, and &#8211; after clicking it &#8211; the dialog message text and the dialog &#8220;Ok&#8221; button.</p>
<p>When done, switch back to Jubula. You should see a new editor called &#8220;OM / &lt;something&gt;&#8221;, already containing your logical components on the left side, and the newly recorded test object components on the right side:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/26-objects-yet-unmapped.png"><img class="aligncenter size-full wp-image-171" title="26-objects-yet-unmapped" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/26-objects-yet-unmapped.png" alt="Unmapped components" width="452" height="236" /></a></p>
<p>All that&#8217;s left to do now is to map the logical to the technical component names. You can do this by dragging each logical component name over the respective technical one and drop it there. The editor will change into this:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/27-objects-mapped.png"><img class="aligncenter size-full wp-image-173" title="27-objects-mapped" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/27-objects-mapped.png" alt="All objects mapped" width="450" height="239" /></a></p>
<p>Aaand&#8230; &#8211; we&#8217;re done with the object mapping. Your &#8220;Problems&#8221; view should be empty. This means that we can run our tests, at last! &#8211; Ok, nearly. First, we have to stop the object mapping mode again. I&#8217;m sure you&#8217;ll find the respective toolbar button by yourself. <img src='http://jmhofer.johoop.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Select your &#8220;System Test&#8221; test suite in the &#8220;Test Suite Browser&#8221; view and run it:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/28-run-test-suite.png"><img class="aligncenter size-full wp-image-174" title="28-run-test-suite" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/28-run-test-suite.png" alt="Running the Test Suite" width="394" height="144" /></a></p>
<p>Hopefully, your automated tests will run now. &#8211; You can switch into the Test Execution afterwards and check the results of the test run:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/29-test-run-results.png"><img class="aligncenter size-full wp-image-175" title="29-test-run-results" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/29-test-run-results.png" alt="" width="301" height="289" /></a></p>
<p>Oops, my tests failed. What&#8217;s the matter?</p>
<p>I&#8217;ll go check the screenshot Jubula captured when the &#8220;wait for window&#8221; action failed. It shows a second message tab being open, and zero &#8220;Open Message&#8221; dialogs. Hmmm&#8230;<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/30-failed-test-screenshot.png"><img class="aligncenter size-medium wp-image-176" title="30-failed-test-screenshot" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/30-failed-test-screenshot-300x214.png" alt="" width="300" height="214" /></a></p>
<p>Oh right, I accidentally mapped the wrong toolbar button to my logical &#8220;Open Message&#8221; component&#8230; &#8211; I should have mapped the mail button to it, instead of the green plus sign.</p>
<p>I&#8217;ll correct that (for some reason, I had to restart Jubula before it accepted my fixed object mapping), and maybe you&#8217;ve got a few things to correct, too, and then we&#8217;re done!</p>
<p>You&#8217;ll notice that there will always be some debugging of your test  specifications going on here, unfortunately, but that&#8217;s to be expected:  Specifying tests is like developing in a lot of ways. Also, finding out what exactly made your tests fail can sometimes be harder than it looks, screenshots or not.</p>
<p>Alright, let&#8217;s summarize what we&#8217;ve achieved up to here:</p>
<ul>
<li>In the first part of my blog series, there was some configuration to do in order to get the application under test to cooperate with Jubula. A one time effort.</li>
<li>In the second part, we specified a few tests. This is the part you&#8217;ll have to put the most effort into. You absolutely want to get your test specifications right: Clear, concise, complete, robust, maintainable. This is always difficult to get right. However, in my humble opinion, Jubula gives you a lot of good tools for structuring and refactoring your test specifications to simplify this.</li>
<li>In the third part, we mapped the components and executed the tests. Yay!</li>
</ul>
<p>This should be enough about Jubula to get you started with your own experiments. I hope I tempted you into trying it out! &#8211; It&#8217;s a tool with a lot of potential, at the least.</p>
<p>Before using Jubula in a real-world project, there&#8217;s still a lot of things to clarify, of course, like:</p>
<ul>
<li>What kind of database should you use with Jubula (it defaults to an embedded H2)?</li>
<li>How well does it cope with multiple team members specifying tests at the same time?</li>
<li>How to integrate it into an Ant/Maven/SBT/Gradle/Buildr/whatever build?</li>
<li>How to run it on an Continuous Integration server?</li>
<li>How well do the exported test specifications play together with version control systems?</li>
<li>&#8230; and probably more stuff like that&#8230;</li>
</ul>
<p>But it&#8217;s a start. <img src='http://jmhofer.johoop.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=UI+Testing+with+Eclipse+Jubula%3A+Executing+the+Tests+%283%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D163" title="Post to Twitter"><img class="nothumb" src="http://jmhofer.johoop.de/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=UI+Testing+with+Eclipse+Jubula%3A+Executing+the+Tests+%283%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D163" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://jmhofer.johoop.de/?feed=rss2&#038;p=163</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>UI Testing with Eclipse Jubula: Specifying the Tests (2)</title>
		<link>http://jmhofer.johoop.de/?p=132&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ui-testing-with-eclipse-jubula-specifying-the-tests-2</link>
		<comments>http://jmhofer.johoop.de/?p=132#comments</comments>
		<pubDate>Sun, 15 May 2011 13:43:08 +0000</pubDate>
		<dc:creator>jmhofer</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Jubula]]></category>
		<category><![CDATA[RCP]]></category>

		<guid isPermaLink="false">http://jmhofer.johoop.de/?p=132</guid>
		<description><![CDATA[Last time, I prepared the Eclipse sample RCP mail application as a test object for Jubula. Today, I&#8217;ll try specifying a few tests against it in Jubula. If you&#8217;ve missed the first part, you can find it here. What&#8217;s that about specifying tests? &#8211; Can&#8217;t you just capture and replay them, perhaps? &#8211; Well, no, [...]]]></description>
				<content:encoded><![CDATA[<p>Last time, I prepared the Eclipse sample RCP mail application as a test object for <a title="Eclipse Jubula" href="http://eclipse.org/jubula" target="_blank">Jubula</a>. Today, I&#8217;ll try specifying a few tests against it in Jubula. If you&#8217;ve missed the first part, you can <a title="UI Testing with Eclipse Jubula, Part 1" href="http://jmhofer.johoop.de/?p=97">find it here</a>.</p>
<p>What&#8217;s that about specifying tests? &#8211; Can&#8217;t you just capture and replay them, perhaps? &#8211; Well, no, not with Jubula, and not with me, either! The reason is that test scripts created via Capture/Replay have lots of problems with maintainability and robustness. And when you try to refactor Capture/Replay scripts into a good automation, you&#8217;ll notice that it&#8217;s not easier than writing those scripts from scratch with modern test automation tools like Jubula.</p>
<p>Also, Capture/Replay is only possible after the test object already exists (which is normally too late in the lifecycle of a project), and it misleads you into adapting the tests to fit the current behaviour of the test object.</p>
<p>So, let&#8217;s start up Jubula and begin specifying a few tests. After the welcome screen, Jubula greets you with the following prim perspective:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/12-jubula-start.png"><img class="aligncenter size-medium wp-image-134" title="Jubula: Empty Specification Perspective" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/12-jubula-start-300x245.png" alt="Jubula: Empty Specification Perspective" width="300" height="245" /></a></p>
<p>If you look at it very closely, you&#8217;ll find a small hint about what to do next within the Problems view:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/13-jubula-hints.png"><img class="aligncenter size-full wp-image-135" title="Jubula Hints" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/13-jubula-hints.png" alt="Jubula Hints" width="263" height="120" /></a></p>
<p>However, it doesn&#8217;t tell you how to create a new project. Surprisingly, you won&#8217;t find it in the File menu, but in the Test menu <em>(Test/New&#8230;)</em>:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/09-Test-New.png"><img class="aligncenter size-medium wp-image-136" title="Creating a new test project, step 1" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/09-Test-New-188x300.png" alt="Creating a new test project, step 1" width="188" height="300" /></a></p>
<p>Choose &#8220;rcp&#8221; as toolkit, give your project a good name and click the &#8220;Next&#8221; button. Now you&#8217;ve got to tell Jubula about your test object (Jubula calls it &#8220;AUT&#8221; for &#8220;application under test&#8221;):<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/09-Test-New-2.png"><img class="aligncenter size-medium wp-image-139" title="Creating a new test project, step 2" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/09-Test-New-2-219x300.png" alt="Creating a new test project, step 2" width="219" height="300" /></a></p>
<p>Choose a name for your test object and ensure, that the &#8220;rcp&#8221; toolkit is selected. Don&#8217;t worry about AUT IDs for now. Press the &#8220;Next&#8221; button for the last step: configuring your test object:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/09-Test-New-3.png"><img class="aligncenter size-medium wp-image-140" title="Creating a new test project, step 3" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/09-Test-New-3-300x271.png" alt="Creating a new test project, step 3" width="300" height="271" /></a></p>
<p>Give your configuration a good name, and set an &#8220;AUT ID&#8221; for it, too. But mainly, select the executable of your RCP application, then click &#8220;Finish&#8221;. &#8211; At last, we&#8217;re done with creating the test project.</p>
<p>Note (in the top right) that we&#8217;ve already got the correct perspective open: the &#8220;Functional Test Specification&#8221; perspective. When specifying tests in a top-down way, you&#8217;ll at first mostly work with the &#8220;Test Case Browser&#8221; view (bottom left), with the editor pane, of course, and with the &#8220;Properties&#8221; view (top right).</p>
<p>To begin with, let&#8217;s create two levels of abstraction for structuring our tests (for complex applications, you probably want more than two): &#8220;Use Cases&#8221; and &#8220;Basic Interactions&#8221;. Create these as new categories in the Test Case Browser. Notice how the &#8220;Use Cases&#8221; gets sorted (alphabetically) after the system library test cases of your toolkit (&#8220;unbound modules&#8230;&#8221;). If you don&#8217;t like that, you can always prefix your categories.</p>
<p>Let&#8217;s test the opening of mail messages first. I created another category for that under the &#8220;Use Cases&#8221;. What are our use cases for opening mail messages in that simple application? Well, we can open a message by menu, by keyboard shortcut or by toolbar button. And afterwards, we can check whether the &#8220;Open Message Dialog&#8221; appears correctly. That&#8217;s it. Here are my test cases:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/14-test-cases-use-cases.png"><img class="aligncenter size-full wp-image-143" title="14-test-cases-use-cases" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/14-test-cases-use-cases.png" alt="" width="308" height="268" /></a></p>
<p>Alright, now we can open our first test case &#8220;Open Message via Menu&#8221; in an editor:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/15-open-message-via-menu.png"><img class="aligncenter size-full wp-image-145" title="Empty Test Case Editor" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/15-open-message-via-menu.png" alt="Empty Test Case Editor" width="358" height="455" /></a></p>
<p>A lot of empty space to fill&#8230; &#8211; what are the basic interactions this test case consists of? I&#8217;d say we have to find and select the correct menu entry first, and then check for the dialog next. So let&#8217;s create these two basic interactions (I already created the basic interactions for the other use case level test cases, too):<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/16-all-test-cases.png"><img class="aligncenter size-full wp-image-146" title="Use Cases and Basic Interactions" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/16-all-test-cases.png" alt="Use Cases and Basic Interactions" width="309" height="366" /></a></p>
<p>Now that we have declared the required basic interactions, we can drag and drop them into the editor, and even rename the references afterwards in the Properties view (not very necessary in this simple case, where there are no parameters, but in general, I&#8217;d always do that):<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/17-test-case-editor1.png"><img class="aligncenter size-medium wp-image-150" title="17-test-case-editor" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/17-test-case-editor1-300x70.png" alt="" width="300" height="70" /></a></p>
<p>Up to now, we&#8217;re still on an abstract level without any toolkit interactions. But that&#8217;s going to change when we specify how our basic interactions work.</p>
<p>Let&#8217;s start with opening the &#8220;File&#8221; / &#8220;Open Message&#8221; menu entry. We&#8217;re looking for a way to select a menu bar entry. So, let&#8217;s open up the &#8220;unbound_modules_concrete&#8221; tree in the Test Case Browser, and then look under &#8220;Actions (basic) / Select / Menu Bar / ub_mbr_selectEntry_byTextpath&#8221;. That should be the right one. Drag it into the Test Case Editor of your basic interaction.</p>
<p>Nearly done. Now give it a good name in the &#8220;Properties&#8221; view, and set the two parameter values. The value for <code>TEXTPATH</code> should be <code>/File/Open Message*</code>, and the value for <code>OPERATOR</code> should be <code>simple match</code> (or you could do the same with <code>matches</code> and a proper regular expression in <code>TEXTPATH</code>).</p>
<p>Now your test case should look similar to this:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/18-open-message-basic.png"><img class="aligncenter size-medium wp-image-154" title="18-open-message-basic" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/18-open-message-basic-300x116.png" alt="" width="300" height="116" /></a></p>
<p>Next let&#8217;s specify how to check the dialog: First, we want to wait until an &#8220;Open&#8221; dialog appears, then we want to check that it displays the correct text, and finally we want to close it again by pressing the &#8220;Ok&#8221; button. This means, that for this test case, we need a sequence.</p>
<p>So, find the basic concrete action &#8220;Wait / Application / Wait for Window / ub_app_waitForWindow&#8221; and add it to your test case. You now have to configure a few properties again, namely <code>TITLE</code>, <code>OPERATOR</code>, <code>TIMEOUT_IN_MILLISECS</code> and <code>DELAY_AFTER_VISIBILITY</code>:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/19-wait-for-dialog.png"><img class="aligncenter size-medium wp-image-156" title="Wait for the &quot;Open&quot; dialog" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/19-wait-for-dialog-300x155.png" alt="Wait for the &quot;Open&quot; dialog" width="300" height="155" /></a></p>
<p>Then, find the action &#8220;Check / Component with Text / ub_ctx_checkText&#8221; and append it to your test case. Enter the parameter values as always. But now, there&#8217;s something new to do. We have to tell Jubula the text of which component we want to check, and we do that in the &#8220;Component Names&#8221; view (in the lower right). In there, under &#8220;New Name&#8221;, just enter an identifier that makes it easy for you to remember which component it is (I chose &#8220;open_message_dialog_text&#8221;):<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/20-check-text-in-dialog.png"><img class="aligncenter size-medium wp-image-157" title="Check the text in the dialog" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/20-check-text-in-dialog-300x108.png" alt="Check the text in the dialog" width="300" height="108" /></a></p>
<p>Later, when you want to execute your tests, you&#8217;ll need to map these  component identifiers to the physical components of your test object.  This is called object mapping, but we&#8217;ll handle that later on.</p>
<p>Alright. Now, only the button click is missing. It&#8217;s in the basic actions category, too, under &#8220;Click&#8221; / &#8220;ub_grc_clickLeft_single&#8221;. There&#8217;s no properties to set this time (except for the reference name), but again, we have to tell Jubula that we want it applied to the &#8220;Ok&#8221; button of the dialog by telling it how we want to call our logical component (I chose &#8220;open_message_dialog_ok_button&#8221;):<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/21-click-ok-button.png"><img class="aligncenter size-medium wp-image-158" title="Click the &quot;Ok&quot; button" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/21-click-ok-button-300x131.png" alt="Click the &quot;Ok&quot; button" width="300" height="131" /></a></p>
<p>And finally, we&#8217;re done with our first check.</p>
<p>I&#8217;ll leave specifying the two other basic test cases &#8220;Open message via toolbar&#8221; and &#8220;Open message via shortcut&#8221;, and filling in the two other use case level test cases to you, as an exercise. <img src='http://jmhofer.johoop.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>When you&#8217;re done, we can collect the fruits of our work in a test suite. Within the &#8220;Test Suite Browser&#8221;, create a new test suite called &#8220;System Test&#8221; (for example), and open it in an editor. Now drag all your use cases into the test suite:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/22-the-test-suite.png"><img class="aligncenter size-medium wp-image-159" title="Finally: the complete test suite" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/22-the-test-suite-300x275.png" alt="Finally: the complete test suite" width="300" height="275" /></a></p>
<p>Don&#8217;t worry if you see problems in the &#8220;Problems&#8221; view. They probably tell you that you haven&#8217;t done the object mapping yet. &#8211; We&#8217;re done specifying our tests, but we can&#8217;t execute them yet!</p>
<p>And that means that there&#8217;s more left to do in <a title="Running the Tests" href="http://jmhofer.johoop.de/?p=163">my next blog entry</a>&#8230; <img src='http://jmhofer.johoop.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=UI+Testing+with+Eclipse+Jubula%3A+Specifying+the+Tests+%282%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D132" title="Post to Twitter"><img class="nothumb" src="http://jmhofer.johoop.de/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=UI+Testing+with+Eclipse+Jubula%3A+Specifying+the+Tests+%282%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D132" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://jmhofer.johoop.de/?feed=rss2&#038;p=132</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UI Testing with Eclipse Jubula: Preparing the Test Object (1)</title>
		<link>http://jmhofer.johoop.de/?p=97&#038;utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=ui-testing-with-eclipse-jubula-preparing-the-test-object-1</link>
		<comments>http://jmhofer.johoop.de/?p=97#comments</comments>
		<pubDate>Fri, 13 May 2011 19:52:22 +0000</pubDate>
		<dc:creator>jmhofer</dc:creator>
				<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[Jubula]]></category>
		<category><![CDATA[RCP]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://jmhofer.johoop.de/?p=97</guid>
		<description><![CDATA[Recently, Bredex created an interesting product at the Eclipse Foundation: namely, Jubula, a tool for UI testing Eclipse RCP, SWT, Swing and web applications. Basically, I guess this will become the &#8220;community edition&#8221; of GUIDancer, which is good enough for me, considering the dire need for any free UI testing tool for RCP, SWT or [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, <a title="Bredex" href="http://www.bredex.de/en/home/first.html" target="_blank">Bredex</a> created an interesting product at the Eclipse Foundation: namely, <a title="Eclipse Jubula" href="http://eclipse.org/jubula" target="_blank"><strong>Jubula</strong></a>, a tool for UI testing Eclipse RCP, SWT, Swing and web applications. Basically, I guess this will become the &#8220;community edition&#8221; of <a title="GUIDancer" href="http://bredex.de/en/guidancer/first.html" target="_blank">GUIDancer</a>, which is good enough for me, considering the dire need for any free UI testing tool for RCP, SWT or Swing at all.</p>
<p>I won&#8217;t go into comparisons with other tools in this post, but in short, imho, though there may be better tools for web testing, though there may be alternatives for Swing testing, though there may be better commercial tools for testing RCP and SWT, when you&#8217;re looking for<strong> free tools for testing RCP/SWT</strong>, I think you should start with<strong> Jubula</strong>.</p>
<p>Unfortunately, working with Jubula turns out to be a bit unwieldy at first. &#8211; So I&#8217;ll try to give a detailed step-by-step guide to your first GUI test automation with Jubula here, using a simple Eclipse RCP sample project as the test object.</p>
<p>So, let&#8217;s start with setting up the test object first: Open up Eclipse and create a new plug-in project <em>(File/New/Project&#8230;/Plug-in Development/Plug-in Project)</em>:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/01-rcp-sample-wizard.png"><img class="aligncenter size-medium wp-image-99" title="New Plug-in Project Wizard, Page 1" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/01-rcp-sample-wizard-258x300.png" alt="New Plug-in Project Wizard, Page 1" width="258" height="300" /></a></p>
<p>Next, tell Eclipse that it&#8217;s a rich client application:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/02-rcp-sample-wizard-2.png"><img class="aligncenter size-medium wp-image-103" title="New Plug-in Project Wizard, Page 2" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/02-rcp-sample-wizard-2-258x300.png" alt="New Plug-in Project Wizard, Page 2" width="258" height="300" /></a></p>
<p>And finally, choose the &#8220;RCP Mail&#8221; template:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/03-rcp-sample-wizard-3.png"><img class="aligncenter size-medium wp-image-105" title="New Plug-in Project Wizard, Page 3" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/03-rcp-sample-wizard-3-258x300.png" alt="New Plug-in Project Wizard, Page 3" width="258" height="300" /></a></p>
<p>Now, let&#8217;s see what we&#8217;ve got in our workspace:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/04-warnings.png"><img class="aligncenter size-medium wp-image-108" title="The Mail RCP project, with warnings" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/04-warnings-300x206.png" alt="The Mail RCP project, with warnings!" width="300" height="206" /></a></p>
<p>Hey, wait, what&#8217;s that, warnings about raw types? &#8211; We can&#8217;t tolerate that. I&#8217;ll quickly fix these by turning the <code>List</code> into a <code>List&lt;TreeObject&gt;</code>:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/05-warnings-fixed.png"><img class="aligncenter size-medium wp-image-110" title="Fixing the warnings" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/05-warnings-fixed-300x75.png" alt="Fixing the warnings" width="300" height="75" /></a></p>
<p>That was easy. Actually, why do they have these warnings in their sample code at all? &#8211; Anyway, what&#8217;s next? Right, let&#8217;s try if it works:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/06-ok-it-runs.png"><img class="aligncenter size-medium wp-image-111" title="Ok, it runs" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/06-ok-it-runs-300x200.png" alt="Ok, it runs" width="300" height="200" /></a></p>
<p>Looking good. This should be simple enough for our first steps, yet complex enough to play around a bit. &#8211; However, for exporting the application, we&#8217;re missing a product configuration <em>(File/New/Product Configuration)</em>:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/07-create-product-configuration.png"><img class="aligncenter size-medium wp-image-112" title="Creating a product configuration" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/07-create-product-configuration-229x300.png" alt="Creating a product configuration" width="229" height="300" /></a></p>
<p>Alright, now we&#8217;re set for exporting the RCP application as Eclipse product <em>(File/Export&#8230;/Eclipse product)</em>:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/08-export-eclipse-product.png"><img class="aligncenter size-medium wp-image-113" title="Exporting the RCP product" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/08-export-eclipse-product-298x300.png" alt="Exporting the RCP product" width="298" height="300" /></a></p>
<p>Finally, we&#8217;re done with preparing our test object. Or are we?</p>
<p>Actually, we&#8217;re not, unfortunately. The reason for this is that sadly, the Eclipse JFace/SWT libraries haven&#8217;t got any easy way to access/instrument them for automation on the fly (unlike Swing).</p>
<p>So, Jubula has to somehow hook itself into our RCP application, and we have to help with that: Look for the archive <code>rcp-support.zip</code> in your Jubula installation directory and extract it into your product directory. This will add a Jubula instrumentation plugin to your product.</p>
<p>However, that&#8217;s not all. You&#8217;ve still got to activate that plugin, and you can do that by editing the <code>configuration/config.ini</code> file in your product directory. There&#8217;s a long line in that file listing the <code>osgi.bundles</code>, and you have to add the Jubula plugin at the end:<a href="http://jmhofer.johoop.de/wp-content/uploads/2011/05/10-configure-test-object-osgi.png"><img class="aligncenter size-medium wp-image-115" title="Configuring the OSGi bundles" src="http://jmhofer.johoop.de/wp-content/uploads/2011/05/10-configure-test-object-osgi-300x166.png" alt="Configuring the OSGi bundles" width="300" height="166" /></a></p>
<p>Phew. Now we&#8217;re really really done with preparing the test object. Of course, for real projects, you&#8217;ll probably want to automate all these preparations in your build.</p>
<p>Let&#8217;s start up Jubula and do some testing! &#8211; Or wait, actually, let&#8217;s do that in <a title="UI Testing with Eclipse Jubula: Specifying the Tests (2)" href="http://jmhofer.johoop.de/?p=132">my next blog post.</a> <img src='http://jmhofer.johoop.de/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<div class="tweetthis" style="text-align:left;"><p> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=UI+Testing+with+Eclipse+Jubula%3A+Preparing+the+Test+Object+%281%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D97" title="Post to Twitter"><img class="nothumb" src="http://jmhofer.johoop.de/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a target="_blank" rel="nofollow" class="tt" href="http://twitter.com/intent/tweet?text=UI+Testing+with+Eclipse+Jubula%3A+Preparing+the+Test+Object+%281%29+http%3A%2F%2Fjmhofer.johoop.de%2F%3Fp%3D97" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://jmhofer.johoop.de/?feed=rss2&#038;p=97</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>
