blog.lesspainful.com http://blog.lesspainful.com/ Blog about Calabash-iOS, Calabash-Android and LessPainful.com en-us Wed, 17 Apr 2013 13:03:04 -0700 Wed, 17 Apr 2013 13:03:04 -0700 Test engineering for Cross-platform testing http://blog.lesspainful.com/2013/03/28/CrossPlatform-and-TestEngineering Thu, 28 Mar 2013 00:00:00 -0700 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2013/03/28/CrossPlatform-and-TestEngineering <h1>Test engineering for Cross-platform</h1> <p>One of the promises of Calabash is <em>cross-platform</em> testing. What we mean by this is the ability to maximize code- and specification reuse when developing the same app (or similar apps) for multiple platforms (e.g. iPhone, iPad, Android Phone, Android Tablet, Mobile Web, Desktop Web,&hellip;).</p> <p>However, it may not immediately apparent how to do this. We do not recommend the use of the Calabash pre-defined steps &ndash; these are there only for beginners and to get results quickly. For larger, serious test suites, pre-defined steps should be completely avoided.</p> <p>We&rsquo;ve written an <a href="https://github.com/calabash/calabash-ios/blob/0.9.x/calabash-cucumber/doc/x-platform-testing.md">article about cross-platform testing with Calabash</a> which comes along with the accompanying <a href="https://github.com/calabash/x-platform-example">sample code</a> based on the open source Wordpress app.</p> <p>LessPainful also offers a <a href="https://www.lesspainful.com/pricing">number of services</a> to support the <a href="http://calaba.sh">Calabash</a> project. One of the most popular services has been on-site training for companies adopting Calabash. In the training class we teach how you use Calaash efficiently as well as cross-platform and test engineering best practices. Contact us as <a href="mailto:contact@lesspainful.com">contact@lesspainful.com</a> for more information.</p> <p>Cross-platform testing does not mean 100% code-reuse across platforms. This may seem disappointing at first, but when you consider the fact that well-designed UIs are different for different platforms, even if you&rsquo;re build the same app, then this becomes immediately clear. Instead, what we should hope for is to reuse the parts of the testing code that should be the same: the specifications and step definitions.</p> <p>For example consider these screens from the wordpress app:</p> <p><img src="/img/wordpress_apps.jpeg" style="width:80%; height:80%;"></p> Testing Multiple Android Apps http://blog.lesspainful.com/2013/03/15/Testing-Multiple-Android-Apps Fri, 15 Mar 2013 00:00:00 -0700 jonas@lesspainful.com (Jonas Maturana Larsen) http://blog.lesspainful.com/2013/03/15/Testing-Multiple-Android-Apps <h1>Testing Multiple Android Apps</h1> <p>The default setup for Calabash-Android is to test a single Android application at a time. <code>calabash-android gen</code> wil generate hooks that will install, launch and uninstall at appropriate times to support the single app use case. However, sometimes it can be useful to interact with multiple apps at the same time. This blog post will dig into details of calabash-android that you might not have touched before.</p> <p><em>Notice that this post is written based on the current pre release of Calabash Android (0.4.3.pre3)</em></p> <h2>Primer: Calabash-Android architecture</h2> <p>Calabash-Android has a client-server architecture where client and server communicate via HTTP. The responsibilites are split like this:</p> <ul> <li><p><em>Client</em> The client sends commands to the test server using <code>performAction</code>, <code>query</code> a number of other methods. Besides the communication, the client is responsible for installing, starting, stopping the test server.</p></li> <li><p><em>Test Server</em> The test server is an instrumentation app that has special permissions to access your app. When a test server is launched it will start an HTTP server on a specified port, start your app and start waiting for requests.</p></li> </ul> <p>By the nature of the Android instrumentation framework, each test server can only test a single app, so to achive multi-app-testing we need to do something special.</p> <p>When you test an app using the generated project structure, the test server will be installed and started on the single device or emulator you have connected to your computer. The test server will listen on port 7102 and <code>localhost:34777</code> will be setup to forward to <code>device:7102</code> over USB. All requests from the client is sent to this default test server.</p> <p>So to test multiple apps, all we need to do is to start multiple test servers. We then configure the client to send requests to each app in turn. Let&rsquo;s see how we can do that.</p> <h2>Testing Multiple Apps</h2> <p>Let&rsquo;s assume that we have two apps called <code>app1.apk</code> and <code>app2.apk</code> located in the root of our project folder.</p> <p>Create the test servers like this:</p> <pre><code>calabash-android build app1.apk calabash-android build app2.apk </code></pre> <p>If you put the following in your <code>features/support/app_installation_hooks.rb</code> and remove <code>features/support/app_life_cycle_hooks.rb</code> you will get two test servers started when executing <code>calabash-android run</code>: one listening on port 7103 and another listening on port 7104.</p> <pre><code>require 'calabash-android/management/app_installation' AfterConfiguration do |config| path1 = File.expand_path("app1.apk") @@app1 = Calabash::Android::Operations::Device.new( self, nil, "34801", path1, test_server_path(path1), 7103) path2 = File.expand_path("app2.apk") @@app2 = Calabash::Android::Operations::Device.new( self, nil, "34802", path2, test_server_path(path2), 7104) end Before do |scenario| extend Calabash::Android::Operations @@app2.reinstall_apps @@app2.start_test_server_in_background @@app1.reinstall_apps @@app1.start_test_server_in_background set_default_device(@@app1) end </code></pre> <p>All requests including those from predifined steps will now be send to app1 running on <code>localhost:34801</code>.</p> <p>To start communicating with app2 simply call <code>set_default_device(@@app2)</code>.</p> Calabash Training http://blog.lesspainful.com/2013/01/15/CalabashTraining Tue, 15 Jan 2013 00:00:00 -0800 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2013/01/15/CalabashTraining <h1>Intensive Calabash Training</h1> <p>LessPainful offers a <a href="https://www.lesspainful.com/pricing">number of services</a> to support the <a href="http://calaba.sh">Calabash</a> project. One of the most popular services has been on-site training for companies adopting Calabash. However, until now these courses have been on-site and for single companies only.</p> <p><img src="/img/training_karl.jpeg" style="float:left; margin-right:10px"> We&rsquo;ll now run our first public training course, which will be held in London on February 11th-12th. To get the most effective training, we&rsquo;ll accept at most 15 participants so reserve your spot now! To register, please use <a href="https://www.lesspainful.com/pricing/training">London training registration form</a>.</p> <p>Although the first course is in London, we&rsquo;d be interested in hearing from you if you&rsquo;d like to attend training, but cannot make it to London. If you prefer a different location or time for the next training let us know by mailing to <a href="mailto:contact@lesspainful.com?subject=Calabash%20Training">LessPainful Contact</a>.</p> <h2>Benefits of Training</h2> <p>Learning a new technology on your own can be time-consuming, and it&rsquo;s always hard to know if you&rsquo;re doing it right! Calabash is a powerful tool, but different ways of using it lead to different degrees of success. Advanced topics such as structuring for cross-platform testing, using the query language effectively, and testing hybrid apps can be hard to learn on your own.</p> <p>The Calabash training will be taught by the creators of Calabash, and we have several years experience with mobile testing and development. The training is centered around guided hands-on exercises to ensure you are able to use the tool efficiently in practice. We&rsquo;ve developed the course based on our experiences running successful on-site private courses. The material has been expanded to cover the latest development, e.g., query support on Android and UIAutomation support on iOS.</p> <p>The courses is two full days, and we will cover a basic introduction to Ruby and Cucumber, although the main focus on Calabash Android and Calabash iOS.</p> <p>Please see the <a href="https://www.lesspainful.com/pricing/training">London training registration form</a> for a more complete agenda!</p> <p>Hope to see you there!</p> A query language for Android views http://blog.lesspainful.com/2012/12/18/Android-Query Tue, 18 Dec 2012 00:00:00 -0800 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/12/18/Android-Query <h1>A Query Language for Android Views</h1> <p><em>Update</em>: Karl, February 25th, 2013. Updated with newest features in query. This is not a complete specification. For details refer to <a href="https://github.com/calabash/calabash-android/wiki/05-Query-Syntax">the wiki</a>.</p> <p>Back in September we published a <a href="http://blog.lesspainful.com/2012/09/02/Calabash-Roadmap/">roadmap for Calabash in the short to medium term</a>. One of the key things on the roadmap was implementing a query language for Calabash Android. The query language will bring additional expressive power to Android tests. Test scripts can become much more dynamic, which removes the need for many of the extensions in the form of custom actions that users of Calabash Android are currently making.</p> <p>Query-language support has now been released in Calabash Android. So please update to the latest version (0.4.2 at the time of this writing).</p> <h2>Let&rsquo;s see some code!</h2> <p>We&rsquo;ll use the WordPress app (<a href="https://github.com/calabash/x-platform-example">details on how to get up and running here</a>. To get started download wordpress using the following (which requires sub-version, svn, installed)</p> <pre><code>krukow:~/tmp/query$ mkdir -p android-source krukow:~/tmp/query$ cd android-source krukow:~/tmp/query/android-source$ svn co http://android.svn.wordpress.org/tags/2.2.7/ krukow:~/tmp/query/android-source$ cd 2.2.7/ krukow:~/tmp/query/android-source/2.2.7$ ant debug Buildfile: /Users/krukow/tmp/query/android-source/2.2.7/build.xml … </code></pre> <p>Now from the directory containing android-source, connect and Android device (or emulator) and do:</p> <pre><code>krukow:~/tmp/query$ calabash-android console android-source/2.2.7/bin/Dashboard-debug.apk No test server found for this combination of app and calabash version. Recreating test server. Done signing the test server. Moved it to test_servers/63a7fdd310c543c9e27773d4207823d2_0.4.2.apk </code></pre> <p>Now reinstall and launch:</p> <pre><code> irb(main):001:0&gt; reinstall_apps … =&gt; nil irb(main):002:0&gt; start_test_server_in_background nil </code></pre> <p>This starts the app on the device:</p> <p><img src="/img/cal-android-login1.png" alt="Simple sample app main screen with two buttons and two edit text fields"></p> <p>Time to actually try query. Let&rsquo;s query for all buttons in the current view:</p> <pre><code>irb(main):003:0&gt; buttons = query("button") [ [0] { "id" =&gt; "button1", "enabled" =&gt; true, "contentDescription" =&gt; nil, "class" =&gt; "android.widget.Button", "text" =&gt; "Accept", "rect" =&gt; { "center_y" =&gt; 434.5, "center_x" =&gt; 89.0, "height" =&gt; 55, "y" =&gt; 407, "width" =&gt; 146, "x" =&gt; 16 }, "description" =&gt; "android.widget.Button@40573488" }, [1] { "id" =&gt; "button2", "enabled" =&gt; true, "contentDescription" =&gt; nil, "class" =&gt; "android.widget.Button", "text" =&gt; "Decline", "rect" =&gt; { "center_y" =&gt; 434.5, "center_x" =&gt; 233.0, "height" =&gt; 55, "y" =&gt; 407, "width" =&gt; 146, "x" =&gt; 160 }, "description" =&gt; "android.widget.Button@40558a10" } ] </code></pre> <p>As we can see there are two buttons: one with text <code>"Accept"</code> and id <code>"button1"</code>, and one with text <code>"Decline"</code> and id <code>"button2"</code>. We can use <code>index</code> to select one of those:</p> <pre><code>irb(main):004:0&gt; query("button index:0") [ [0] { "id" =&gt; "button1", "enabled" =&gt; true, "contentDescription" =&gt; nil, "class" =&gt; "android.widget.Button", "text" =&gt; "Accept", "rect" =&gt; { "center_y" =&gt; 434.5, "center_x" =&gt; 89.0, "height" =&gt; 55, "y" =&gt; 407, "width" =&gt; 146, "x" =&gt; 16 }, "description" =&gt; "android.widget.Button@40573488" } ] </code></pre> <h1>Filtering based on properties</h1> <p>Using <code>index</code> often leads to brittle tests that may break if the user interface changes. On iOS there is a concept of a &ldquo;mark&rdquo; &mdash; a general way of identifying views.</p> <p>The notion of <code>mark</code> also exists in Calabash Android: here it means view selection by one of the properties <code>id</code>, <code>contentDescription</code> or simply <code>text</code>. Here is an example:</p> <pre><code>irb(main):005:0&gt; query("button marked:'Accept'") [ [0] { "id" =&gt; "button1", "text" =&gt; "Accept", ... } ] </code></pre> <p>In general you can filter based on any &ldquo;property&rdquo; of a view. A property is defined as any piece of data you can access by calling a getter on the view. (Actually, any simple data you can extract by calling a no-arg method is a &ldquo;property&rdquo;)</p> <p>For example, let&rsquo;s filter the buttons by matching against the value of their <code>getText</code> method instead:</p> <pre><code>irb(main):006:0&gt; query("button text:'Accept'") #same result </code></pre> <p>Right now, only integer, string, boolean and null data types are supported. Strings are written in single quotes <code>'a string'</code>. More exact details on what happens is described in the Wiki page about <a href="https://github.com/calabash/calabash-android/wiki/05-Query-Syntax">query syntax</a>.</p> <h1>Filtering based on classes</h1> <p>The first query we saw in this post was <code>query("button")</code> &ndash; this is actually querying for all <em>visible</em> views which have <em>a class with &ldquo;simple name&rdquo;</em>: <code>"button"</code> (simple name is the last segment of the fully qualified name). The comparison is case insensitive so this will match the class: <code>android.widget.Button</code>.</p> <p>You can also match on a qualified class name, e.g., <code>query("android.view.View")</code> will match all views of type <code>"android.view.View"</code> (or subtypes thereof).</p> <p>There is an important distinction between iOS and Android here: on iOS there is a &ldquo;magic&rdquo; translation from say <code>label</code> to <code>UILabel</code> (the class in <code>UIView</code>). There is no such translation on Android, only matching based on (sub-) type of a class or simple name for convenience.</p> <p>Another important distiction is that only fully qualified queries match also sub-types. So if you have a sub-class of <code>android.widget.Button</code> say <code>com.example.AwesomeButton</code> this will not be found with <code>query("button")</code> but it will with <code>query("android.widget.Button")</code>. So, at least right now, the &ldquo;simple-name&rdquo; notation is restricted.</p> <p>Also, there is a short-hand notation for &ldquo;android.view.View&rdquo; which is simply &ldquo;*&rdquo; (e.g., <code>query("*")</code>).</p> <h1>View hierarchy</h1> <p>On iOS you can navigate the view hierarchy, for example <code>query("tableViewCell index:0 label")</code> finds all labels inside the first table cell.</p> <p>Here is an Android example:</p> <pre><code>irb(main):010:0&gt; query("* id:'buttonPanel' button text:'Accept'") #same result yet again... </code></pre> <p>This reads as &ldquo;find a view with id &lsquo;buttonPanel&rsquo;, then inside of that find a button with text &lsquo;Accept&rsquo;&rdquo;.</p> <p>On iOS you can navigate up and down the hierarchy. This is also supported on Android. Here is a powerful example:</p> <pre><code>irb(main):011:0&gt; query("* id:'buttonPanel' button text:'Accept' sibling button") [ [0] { "id" =&gt; "button2", "enabled" =&gt; true, "contentDescription" =&gt; nil, "class" =&gt; "android.widget.Button", "text" =&gt; "Decline", "rect" =&gt; { "center_y" =&gt; 274.5, "center_x" =&gt; 353.0, "height" =&gt; 55, "y" =&gt; 247, "width" =&gt; 226, "x" =&gt; 240 }, "description" =&gt; "android.widget.Button@40558a10" } ] </code></pre> <p>This finds the &ldquo;sibling&rdquo; button of &ldquo;Accept&rdquo;, namely the &ldquo;Decline&rdquo; button. You can also navigate in these directions: descendant, child, parent (descendant being the default).</p> <h1>Property extraction</h1> <p>Just as on iOS, you can extract properties by providing more than one argument to the query function:</p> <pre><code>irb(main):020:0&gt; query("button",:text) [ [0] "Accept", [1] "Decline" ] </code></pre> <p>Here, the <code>android.widget.Button</code> views are found, and text is extracted via a <code>text()</code>, <code>getText()</code> or <code>isText()</code> method.</p> <p>Several arguments can be supplied, in which case the process continues:</p> <pre><code>irb(main):021:0&gt; query("button", :text, :length) [ [0] 6, [1] 7 ] </code></pre> <p>Do you dare try this: <code>query("button", {:setText =&gt; "No way!"})</code>?</p> <h1>Touch</h1> <p>If you can find it with query, you can touch it! Touching (and other gestures) can be done in two ways. You can provide a query to the <code>touch</code> function: e.g. <code>touch("button text:'Accept'")</code>. Alternatively you can store the result of a past query in a variable: <code>btn = query("button text:'Accept'")</code> and then later <code>touch(btn)</code> (provided of course the button is still visible at the same location).</p> <h1>Conclusion and What&rsquo;s next?</h1> <p>As mentioned in the roadmap, we are working at bringing Calabash Android and Calabash iOS closer together. With query-support in the released 0.4.x line, this is already a big step forward in providing a truely cross-platform testing experience for mobile. We&rsquo;ve also provided an example of cross-platform testing with Calabash which maximizes reuse of test-code across platforms.</p> <p><a href="https://github.com/calabash/x-platform-example">Cross-platform example</a></p> <p>Getting good community feedback on the query language is important to us. So we encourage everyone to try it out and report experiences and bugs to the <a href="http://groups.google.com/forum/?fromgroups#!forum/calabash-android">Calabash Android Group</a> and to submit improvements as <a href="https://github.com/calabash/calabash-android">pull requests</a>.</p> <p>The next blog post will shed some light on how Calabash iOS will improve in the coming months. I think we have some very interesting news here that we&rsquo;re looking forward to sharing with you… Stay tuned.</p> Call for JVM Sponsorships http://blog.lesspainful.com/2012/12/13/Call-for-Sponsorship Thu, 13 Dec 2012 00:00:00 -0800 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/12/13/Call-for-Sponsorship <h1>Call for JVM-support Sponsorships</h1> <h2>Background</h2> <p>In June we started a <a href="http://localhost:4000/2012/06/13/Calabash_JVM_Support/">survey of interest</a> in Java/JVM support for writing and executing Calabash tests. In the last 6 months we&rsquo;ve been speaking at conferences and talking to customers, and JVM support has been a recurring feature request. Our survey for JVM support has now been answered by a number of larger companies all positive around sponsoring JVM support.</p> <p>So now is the time!</p> <h2>Sponsorships</h2> <p>We now have sufficient interest from several larger companies that need JVM support and have indicated interest in sponsoring the development effort.</p> <p>We&rsquo;ve estimated a total cost of $10.000 for us for this development effort. LessPainful itself will sponsor 25% of the effort since it benefits Calabash &mdash; this leaves $7500 that we need to find.</p> <p>Benefits for sponsors</p> <ul> <li><p>Of course, using Java for writing Calabash tests is the most obvious benefit.</p></li> <li><p>All sponsors have the option of having their logo added as a sponsor to the Calabash landing page (<a href="http://calaba.sh">http://calaba.sh</a>).</p></li> <li><p>All sponsors have the option of being mentioned (including the amount sponsored) in an appreciation blog post and tweets by <a href="http://twitter.com/lesspainful">@lesspainful</a>.</p></li> <li><p>Any special JVM feature requests are possible and will be seriously considered for sponsors.</p></li> </ul> <p>Please let us know if you want to contribute to this effort.</p> <h2>Deadline</h2> <p><em>Deadline</em> for accepting is <em>December 21st 2012</em> (if you want to sponsor but cannot fully confirm by 21st, let us know, and we will figure something out).</p> <p>Please contact <a href="mailto:contact@lesspainful.com">contact@lesspainful.com</a> to become a sponsor.</p> <p>After the deadline we will post here whether or not the goal has been reached.</p> Roadmap for Calabash http://blog.lesspainful.com/2012/09/02/Calabash-Roadmap Sun, 02 Sep 2012 00:00:00 -0700 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/09/02/Calabash-Roadmap <h1>Roadmap for Calabash</h1> <p>In this post we&rsquo;ll talk about the history and future of Calabash. A lot has happened since it was first publicly announced about half a year ago in our introductory blog post on <a href="http://blog.lesspainful.com/2012/03/07/Calabash/">Calabash</a>. We&rsquo;ll look at the roadmap for Calabash as we see it, but first a bit of history to explain why things are as they are…</p> <h2>Background</h2> <p><img alt="Calabash Logo" style="float:left; margin-left:10px;margin-right:10px;" src="http://blog.lesspainful.com/img/calabash-logo.png"></p> <p>In January 2012, we decided to change LessPainful&rsquo;s business model. The most significant change was to open source the software that was used to write automated acceptance and functional tests for our clients' mobile apps: <a href="http://calaba.sh/">Calabash</a>. This was a lot of work, and continually is. Thankfully, it is also rewarding to see a community thrive.</p> <p>Infact, it turned out to be the best decision we ever made for LessPainful: it has generated a lot of attention in the mobile space (see <a href="#links">links 1-6</a>) below), it has created an <a href="https://groups.google.com/forum/?fromgroups#!forum/calabash-ios">active</a> <a href="https://groups.google.com/forum/?fromgroups#!forum/calabash-android">community</a> around the software, and it has given LessPainful a number of very serious larger enterprise customers wanting commercial support, training, Calabash extensions and of course our primary product: <a href="http://www.lesspainful.com">Shared and Private Mobile Device Clouds</a>.</p> <p><strong>Before Calabash</strong> was made open source, it existed first as a proprietary library for Android. It was based on Robotium but gave a higher level API and supported Cucumber. The library was used for some time to test our clients' Android apps on real Android devices at <a href="http://www.lesspainful.com">LessPainful</a>. It was clear that many of our clients wanted both Android and iOS support. So I implemented a proof-of-concept of the automation infrastructure for iOS which we needed at LessPainful.com (install/uninstall, start/stop, clear device, change language etc).</p> <p>After doing the POC, we needed a testing library that would let our clients use Cucumber to test also their iOS apps at LessPainful. The iOS library was almost a straight reimplementation of <a href="http://testingwithfrank.com/">Pete Hodgson&rsquo;s Frank</a>, changing only what was necessary to support running on our device clouds at LessPainful (it did also <a href="http://blog.lesspainful.com/2012/03/07/Calabash-iOS/">change some significant parts like touch synthesis</a>).</p> <p><strong>What all this means</strong> is that Calabash started and has evolved as two separate systems. Although they have the same goals (supporting BDD via Cucumber on Android and iOS), the implementations differ as do the interfaces they expose, apart from Cucumber of course.</p> <p>Now, part of the value proposition for Calabash is <em>reusing as much as possible</em> of your testing code when building the same app on iOS and Android (i.e., reusing features and test scripts). Improving this situation will be one of the top priorities for Calabash in the near future.</p> <h2>Bringing Android and iOS Closer</h2> <p><img alt="Android and iOS logos" style="float:right" src="http://blog.lesspainful.com/img/logo_ios_android.gif"> One of the most important goals for Calabash is to reuse features, step definitions and support code across iOS and Android. We&rsquo;ve already begun moving in this direction. For example, Calabash Android has moved to embedding an HTTP server instead of the custom TCP based protocol used before. Soon it will also move to a JSON-based protocol similar to Calabash iOS (which is actually more or less the <a href="http://testingwithfrank.com/frankly.html">Frankly protocol</a>). This moves the server parts of Calabash iOS and Android closer, meaning that clients can be made closer. Here is a good example: <strong>query</strong>.</p> <p>Currently, Calabash iOS has a query language based on UISpec which was inherited from Frank. This query language is immensely useful when writing test scripts &ndash; you can query into any object in the view, find its properties, call methods etc. Calabash Android doesn&rsquo;t support the query language &ndash; and it shouldn&rsquo;t since UISpec is designed around iOS. This is an example where Calabash iOS and Calabash Android will both move away from their current implementation and towards a common query language that makes sense on both platforms. We don&rsquo;t know exactly what this language will look like yet but UISpec has done well for us so far &ndash; so we will design something inspired by that.</p> <p>This will lead to a set of unified APIs that can be used in your iOS and Android test scripts. This is one of our top priorities for Calabash in the near future.</p> <h2>Extending Reach</h2> <p><a href="http://openjdk.java.net/projects/mlvm/"><img alt="Da Vinci Machine Project" title="Da Vinci Machine Project" style="float:right" src="http://blog.lesspainful.com/img/helicopter.png"></a> There are many programmers and QA staff out there that are already familiar with JVM-based languages and tools. Many shops have invested in the JVM both as a platform for development and testing.</p> <p>While we love Ruby and enjoy working with it, we also understand that not everyone has the time or will to learn a new programming language. So while Ruby is a very nice language to work with and has a great ecosystem and community supporting testing, it does restrict the reach of Calabash.</p> <p>For this reason and because there is a good interest (more than 20 companies have declared a strong interest in JVM support), we will be developing <strong>JVM support for Calabash</strong>. BDD will be supported on the JVM via Cucumber JVM, but Calabash JVM itself will be independent of Cucumber.</p> <p>As a proof of concept, and declaration of intent, we have implemented a minimal and prototype JVM version of Calabash iOS. It is implemented in Clojure, but exposes an API that can be called from Java and other JVM-based languages. The project can be found <a href="https://github.com/calabash/calabash-ios/tree/master/calabash-jvm">here</a>, and examples <a href="https://github.com/krukow/calabash-jvm-example">here</a> (Java) and <a href="https://github.com/krukow/calabash-jvm-clojure-example">here</a> (Clojure).</p> <p>While already quite functional, this is only a proof-of-concept. JVM support will not be our first improvement to Calabash. It makes much more sense to first find a good unified API as discussed above. Once we are happy with our unified APIs we can create a JVM implementation much faster.</p> <p><em>JVM support is of high priority to us, but we will develop unified APIs first</em>.</p> <h2>Other improvements</h2> <p>Of course we will continually add features and fix bugs on the Calabash versions you already know. Other potential areas of improvement are</p> <ul> <li><p><strong>Device Cloud</strong>. Better and easier support for running on the LessPainful Device Cloud. There are actually some very juicy bits here that I can&rsquo;t reveal yet :) It will actually be released quite soon, and described in a separate blog post.</p></li> <li><p><strong>Better hybrid/webview support</strong>. While our web view support is actually already quite good, it is also fairly low level. You can query for visible elements and text (this is actually the same API on Android and iOS). You can touch visible elements and enter text. This gets you very far on web views, but it would be nice to have higher level APIs for dealing with common HTML5 components.</p></li> <li><p><strong>Image analysis support</strong>. We are thinking about looking into better support for comparing images. While we prefer scripts that look for text or UI components in views (since they are more robust), we also recognize that there is value in image-based regression analysis. Nicholas Albion has <a href="https://groups.google.com/d/msg/calabash-ios/D0Nx5BJIP-s/I6HDV6GO7FEJ">already done some work on this</a> based on ImageMagick and Zucchini.</p></li> <li><p>&lt;Insert Your suggestion here!&gt; Calabash is <a href="https://github.com/calabash/calabash-android/pulls">truely open source</a>. We will listen to community need, and we will acommodate (provided of course requests are inlined with the direction of Calabash).</p></li> </ul> <p>Stay tuned for more news soon!</p> <p><a name="links"></a></p> <h2>Presentation Links</h2> <ol> <li><a href="http://mobiletestsummit.com/speakers">Sauce Labs Mobile Testing Summit, SF 2012</a></li> <li><a href="www.infoq.com/presentations/Calabash-Functional-Testing">QCon London, London 2012</a> &lt;&ndash; that speaker bio is kinda dated :)</li> <li><a href="http://skillsmatter.com/podcast/home/calabash-an-open-source-automated-testing-technology-for-ios-and-android">CukeUp, London 2012</a></li> <li><a href="http://gotocon.com/amsterdam-2012/presentation/Introducing%20Calabash">Goto Amterdam, Amsterdam 2012</a></li> <li><a href="http://www.youtube.com/watch?v=0an8l1RAe0M">Code Motion, Rome, 2012</a></li> <li><a href="http://www.sqe.com/ConferenceArchive/StarEast2012/ConcurrentThursday.html#T23#T23">StarEast, Orlando, 2012</a></li> </ol> Improved documentation for Calabash iOS http://blog.lesspainful.com/2012/07/10/Calabash-iOS-Documentation Tue, 10 Jul 2012 00:00:00 -0700 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/07/10/Calabash-iOS-Documentation <h2>Documentation for Calabash iOS</h2> <p>I&rsquo;ve done some work to document the previously undocumented API functions needed to write custom steps. I&rsquo;ve also given the documentation an update in general. It is actually getting fairly good (let me know if you disagree!).</p> <p>Checkout these highlights:</p> <p><a href="https://github.com/calabash/calabash-ios/wiki/00-Documentation-overview">Documentation Overview</a></p> <p><a href="https://github.com/calabash/calabash-ios/wiki/01-Getting-started-guide">Getting Started Guide</a></p> <p><a href="https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API">Ruby API</a></p> <p><a href="https://github.com/calabash/calabash-ios/wiki/04-Touch-recording-and-playback">Touch/Event Recording and Playback</a></p> <p><a href="https://github.com/calabash/calabash-ios/wiki/06-WebView-Support">Web View/Hybrid Support</a></p> <p>And finally:</p> <p><a href="https://github.com/calabash/calabash-ios/wiki">EVERYTHING</a>.</p> <p>I&rsquo;ll be complementing these with upcoming screencasts covering: How to work efficiently with Calabash iOS, Tool support, Ruby Tips and Advanced Touch Synthesis.</p> <p>Stay tuned :)</p> Declaration of interest in JVM support for Calabash http://blog.lesspainful.com/2012/06/13/Calabash_JVM_Support Wed, 13 Jun 2012 00:00:00 -0700 karl@lesspainful.com (Karl Krukow and Jonas Maturana Larsen) http://blog.lesspainful.com/2012/06/13/Calabash_JVM_Support <h2>Calabash and JVM support</h2> <p>We are trying to determine how broad interest there is in getting Calabash running on the JVM platform, supporting cucumber-jvm.</p> <p>We would love for people interested in Calabash, to fill out this short form to indicate JVM interest. Comments/discussion here is also ok:</p> <p><a href="https://docs.google.com/spreadsheet/viewform?formkey=dEtCZTlMUHhSdGUtV1Q1YTMzSDNrV0E6MQ">JVM Support interest form</a></p> Speaking at Cukeup! 2012 http://blog.lesspainful.com/2012/04/01/CukeUP Sun, 01 Apr 2012 00:00:00 -0700 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/04/01/CukeUP <h2>Speaking about Calabash at Cukeup! 2012</h2> <p>Things are going well with Calabash &ndash; it&rsquo;s starting to come alive! People are <a href="http://alblue.bandlem.com/2012/03/nsconf-day-3.html">picking it up</a>, they <a href="https://groups.google.com/d/msg/calabash-android/RkorIjABAtg/Z3vOXDSGDjUJ">ask questions</a>, <a href="https://github.com/calabash/calabash-ios/issues/2">post feature requests</a> and <a href="https://groups.google.com/d/msg/nativedriver-users/atbX8EK0NG0/lW8zCuGHao8J">get excited</a>. (as are we!)</p> <p>Thats cool! But we want to spread the word even more. I&rsquo;ve already given talks at <a href="http://qconlondon.com/dl/qcon-london-2012/slides/KarlKrukow_CalabashAnOpenSourceAutomatedTestingTechnologyForNativeMobile.pdf">QCon London 2012</a>, <a href="https://secure.trifork.com/amsterdam-2012/freeevent/index.jsp?eventOID=4054">Goto Night, Amsterdam</a> and <a href="http://www.codemotion.it/en/talk/calabash-open-source-automated-testing-technology-native-mobile">Code motion Rome</a>.</p> <p>Next up is Cuke!, and I&rsquo;m very excited about this one. Cucumber powers Calabash, so I&rsquo;m happy to give something back to the community. I&rsquo;ll be giving a talk about Calabash at <a href="http://skillsmatter.com/event-details/home/cukeup-2012/ac-3691">Cukeup! 2012</a> Wed. April 4 at 14.15 &ndash; 14.45. Hope to see you there!</p> An Overview of Calabash iOS http://blog.lesspainful.com/2012/03/07/Calabash-iOS Wed, 07 Mar 2012 00:00:00 -0800 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/03/07/Calabash-iOS <h2>An Overview of Calabash iOS</h2> <p>Calabsh iOS is a new open source project for functional testing of iPhone and iPad apps based on <a href="http://cukes.info">Cucumber</a>.</p> <p>This post describes <a href="http://github.com/calabash/calabash-ios">Calabash iOS</a> in some technical detail. It will give you an architectural overview and compare Calabash iOS with some other functional testing alternatives (hence, it is fairly advanced and assumes that you are familiar with <a href="http://cukes.info">Cucumber</a> and iOS development).</p> <ul> <li>For an introduction to Calabash and LessPainful (and some info on Cucumber), please read <a href="http://blog.lesspainful.com/2012/03/07/Calabash/">Calabash: Functional Testing for Mobile Apps</a>.</li> <li>Instructions for how to use Calabash in your iOS project can be found in the <a href="http://github.com/calabash/calabash-ios">Github Readme</a>.</li> <li>For a tutorial on how to use Calabash iOS once setup, please see <a href="https://github.com/calabash/calabash-ios/wiki">Getting started guide</a>.</li> </ul> <h2>Calabash Architecture</h2> <p>Calabash tests are executed with the <a href="http://cukes.info">Cucumber tool</a> and consist of three parts:</p> <ul> <li><p><em>Your app</em>, linked with the <code>calabash.framework</code> which embeds an HTTP server in your app (of course, this is only in <em>test builds</em> of your app). The Calabash client library (see next bullet) makes HTTP requests to the server when it wants to do something with the current view.</p></li> <li><p><em>The Calabash client library</em> and <em>step definitions</em>. Calabash supports two types of step definitions: <a href="https://github.com/calabash/calabash-ios/wiki/02-Predefined-steps">built-in</a> and custom. The built-ins define general and domain-neutral steps that are intended to give you a quick and easy start. They contain steps like: <code>I should see a "..." button</code> and <code>I swipe right</code>. The custom steps are written by you, and they&rsquo;re specific to your domain or application. Examples could be: <code>I should be on the Login screen</code>, <code>I login as Pete</code> or <code>I add a track to my playlist</code>. To implement a custom step you can use methods defined in the Calabash <em>client library</em>, calabash-cucumber, which is part of <a href="http://github.com/calabash/calabash-ios">Calabash iOS</a>.</p></li> <li><p><em>Your feature files</em>. The feature files describe the app use-cases you want to test. They are simultaneously a specification of the behaviour of your app and an executable test suite.</p></li> </ul> <p>You can visualize this as:</p> <p><img src="http://blog.lesspainful.com/img/calabash-ios.png" alt="Calabash-iOS architecture" /></p> <p>Calabash iOS supports running on the iOS simulator as well as iPhones, iPads and iPod touches (whether jailbroken or not). The calabash server framework is distributed as a universal framework for your convenience.</p> <p>The client library, calabash-cucumber, is installed using <a href="http://rubygems.org/">RubyGems</a> which is as simple as running <code>gem install calabash-cucumber</code>.</p> <h3>Comparison with other functional testing systems</h3> <p>There are several options out there for functional testing on iOS. Apple provides its <a href="https://developer.apple.com/library/ios/#documentation/DeveloperTools/Reference/UIAutomationRef/_index.html">UIAutomation</a>, there is <a href="http://www.zucchiniframework.org/">Zucchini</a>, <a href="https://github.com/moredip/Frank">Frank</a> by Pete Hodgson, <a href="https://github.com/square/KIF">KIF</a> by square, <a href="http://www.gorillalogic.com/fonemonkey">FoneMonkey</a> by Gorilla Logic, <a href="https://github.com/unboxed/icuke">iCuke</a> by Rob Holland, and probably a few I&rsquo;ve looked at and forgotten again!</p> <p>All the projects have their advantages and disadvantages, Calabash included. But we think that Calabash hits a sweet spot that none other the other options cover.</p> <h3>Frank</h3> <p><a href="https://github.com/moredip/Frank">Frank</a> is the library closest to Calabash; in fact, when we started experimenting with iOS support at LessPainful we started with Frank. Frank is a very cool project by a great person (that&rsquo;s you <a href="https://twitter.com/#!/beingagile">Pete</a>), and Calabash is highly inspired by it. But there were a couple of important reasons why we could not use Frank.</p> <p>First, Frank is licensed using GNU GPLv3 and we wanted to use the less restrictive EPL. Pete actually didn&rsquo;t want to license Frank as GPL, but since Frank is based on UISpec which is GPL'ed, he had to. We did not want the <a href="http://code.google.com/p/uispec/">UISpec</a> project as a dependency.</p> <p>Second, when we started to look at Frank, it was a bit of a pain to set up (in the mean time, its actually gotten much better). It required modification of you app source, inclusion of static resources and source files. We wanted calabash to be easy to set up, so we made Calabash a universal framework.</p> <p>Third, Frank is focused on running in the iOS simulator. We wanted something that ran equally well on simulator, iPhone and iPad. There is no fundamental reason that the Frank architecture shouldn&rsquo;t work on physical devices (indeed Calabash has the same architecture), but many of Frank&rsquo;s step definitions are simulator only.</p> <p>Finally, we needed support for some advanced features that Frank just didn&rsquo;t have. Frank&rsquo;s touch emulation is derived from <a href="http://code.google.com/p/uispec/">UISpec</a>, which has some disadvantages: it only supports tapping, and actually doesn&rsquo;t seem to work in all cases (<a href="https://groups.google.com/group/frank-discuss/tree/browse_frm/month/2011-09/cc1fb65c717180c5">for example on a UISwitch</a>). We wanted support for gestures like swipe, pinch-to-zoom, backgrounding and rotation. We wanted support for querying and acting on UIWebViews.</p> <p>Frank also has the cool Symbiote tool which let&rsquo;s you explore your app from a browser. We don&rsquo;t have Symbiote in Calabash, but instead we have a powerful console based tool for interacting and exploring your application (more on this in a later blog post).</p> <h3>KIF, iCuke, FoneMonkey</h3> <p><em>KIF</em> is another cool project. KIF has an Apache 2.0 license which is ok, but two primary things kept us from going down this route. First, KIF is based on the same touch emulation code as UISpec, and has the same limitations (which actually goes back to a seminal CocoaWithLove post from 2008, <a href="http://cocoawithlove.com/2008/10/synthesizing-touch-event-on-iphone.html">Synthesizing touch events on iPhone</a>). Secondly, KIF tests are written in Objective-C, and we specifically wanted <a href="http://cukes.info">Cucumber</a> for the reasons outlined in the <a href="http://blog.lesspainful.com/2012/03/07/Calabash/">Introductory post</a>.</p> <p><a href="https://github.com/unboxed/icuke">iCuke</a> actually looked very promising two years ago. Unfortunately its author, Rob Holland, has abandoned it, and we had a difficult time proceeding with it.</p> <p><em>FoneMonkey</em>, is GPL licensed and doesn&rsquo;t support Cucumber. FoneMonkey is primarily based on a test recording approach, and we specifically didn&rsquo;t want recording of test scripts since it often leads to large, unreadable and unmaintainable test script . We do actually support a <a href="https://github.com/calabash/calabash-ios/wiki">different form of recording</a> that doesn&rsquo;t suffer from this problem, but that&rsquo;s a topic for another blog post.</p> <h3>UIAutomation and Zucchini</h3> <p>Apple&rsquo;s <em>UIAutomation framework</em> is actually quite advanced in supporting various gestures. It&rsquo;s also simple to set up since it works without modification to the app (runs via instruments). There are a couple of reasons why we decided not to use UIAutomation.</p> <p>First, UIAutomation is not open source &ndash; this means we have to wait for Apple to make bug fixes, and we can&rsquo;t extend it. It is also very poorly documented by Apple, and not that much information available on the net.</p> <p>Second, tests are written in JavaScript using a horrible API, resulting in tests that are too easy to break when making minor changes to the UI (IMHO). The tool for developing and running tests (UIAutomation Instrument) gives an inefficient workflow, for example, by locking the editing file, missing the ability to interactively explore your app and running only parts of a test. Also, screenshotting only works on device.</p> <p>Third, UIAutomation is hard to get working in a continuous integration setup (in fact, when we first looked at it, CI was completely impossible). Extracting tests results and screenshots in a CI friendly way is hard.</p> <p><a href="http://www.zucchiniframework.org/">Zucchini</a>, is a new project that&rsquo;s very cool. It has some great addons for working with app screenshots (we might &lsquo;borrow&rsquo; those for Calabash :), and it makes the developer experience much better by using CoffeeScript instead of JavaScript and by coming with some convenience tools. However, by compiling to UIAutomation compatible JavaScript and running via UIAutomation, it has some of the same problems as UIAutomation itself (lack of documentation, Apple control, the fragility of tests, etc.). Also, we didn&rsquo;t want Calabash users to be required to learn CoffeeScript.</p> <h3>What&rsquo;s next?</h3> <p>So there you have it! A short overview of the Calabash iOS architecture and an overview of similar frameworks.</p> <p>In upcoming posts we&rsquo;ll describe more implementation details of Calabash iOS. For example, we&rsquo;ll show how to make advanced custom steps using the client library API, we&rsquo;ll look at support for rotation and gestures like swiping, and even how you can record your own advanced gestures. We&rsquo;ll also look at an efficient workflow for writing tests in an interactive and exploratory manner.</p> <p>In the meantime please try out <a href="https://github.com/calabash/calabash-ios">Calabash iOS</a>, read the <a href="https://github.com/calabash/calabash-ios/wiki/00-Calabash-iOS-documentation">Project wiki documentation</a>, and tell us what you think: <a href="https://github.com/calabash/calabash-ios/issues">Issues</a> and <a href="https://groups.google.com/forum/?fromgroups#!forum/calabash-ios">Discussion</a>.</p> An Overview of Calabash Android http://blog.lesspainful.com/2012/03/07/Calabash-Android Wed, 07 Mar 2012 00:00:00 -0800 jonas@lesspainful.com (Jonas Maturana Larsen) http://blog.lesspainful.com/2012/03/07/Calabash-Android <h2>An Overview of Calabash Android</h2> <p>This post describes <a href="http://github.com/calabash/calabash-android">Calabash Android</a> in some technical detail. It will give you an architectural overview of Calabash Android and a resume of the functional testing tools available for Android. It assumes that you are familiar with <a href="http://cukes.info">Cucumber</a> and Android development.</p> <ul> <li>For an introduction to Calabash and LessPainful (and some info on Cucumber), please read <a href="http://blog.lesspainful.com/2012/03/07/Calabash/">Calabash: Functional Testing for Mobile Apps</a>.</li> <li>Instructions for how to use Calabash in your Android project can be found on <a href="http://github.com/calabash/calabash-android">Github</a>.</li> </ul> <h2>Calabash Android Architecture</h2> <p>When a Calabash Android test is executed both your local computer and a device is involved. The device might be an emulator or an actual physical device. The setup looks like this: <img src="http://blog.lesspainful.com/img/CalabashAndroidArchitecture.png" alt="Calabash-Android architecture" /></p> <ul> <li><p>Features. The feature files describe the user-stories you want to test. You can test one or more features in one test run.</p></li> <li><p>Step Definitions. Calabash Android comes with a set of predefined step which you can find <a href="https://github.com/calabash/calabash-android/blob/master/ruby-gem/lib/calabash-android/canned_steps.md">here</a>. These steps are generic and made to get you up and running fast. When you get more into Calabash you can implement your own custom steps that use the business terms your project uses like <code>I transfer money to my spendings account</code> or <code>I play "Never Gonna Give You Up"</code>.</p></li> <li><p>Your app. You don&rsquo;t have to make modifications to your app before testing it.</p></li> <li><p>Instrumentation Test Server. This is another app that will be installed and executed the device. This app is based on <code>ActivityInstrumentationTestCase2</code> from the Android SDK. It is generated by the Calabash Android framework.</p></li> </ul> <h2>Functional Testing tools for Android</h2> <p>The Android SDK comes with a testing framework located in the <code>android.test</code> package. <a href="http://developer.android.com/resources/tutorials/testing/helloandroid_test.html">According to Google</a> it is easy to use. However, I&rsquo;m pretty sure that the person who wrote that either never wrote and maintained a test using <code>ActivityInstrumentationTestCase2</code> or has totally misunderstood the &ldquo;easy to use&rdquo; concept. :&ndash;)</p> <p>When <a href="http://www.linkedin.com/pub/renas-reda/25/70a/932">Renas Reda</a> created <a href="http://www.robotium.org">Robotium</a> things became a lot easier. Robotium is a utility that handles a lot of the small details you really don&rsquo;t want to be concerned about in a functional test. You are still writing your test using Java and JUnit but a lot of the very annoying things from vanilla Android testing is now taking care of and don&rsquo;t pollute your tests. Today all the Android projects that I know of that do any kind of testing use Robotium or Calabash. So if you are still fighting <code>android.test</code> and want to clean up your tests you should give Robotium a try and send Renas a happy thought.</p> <p>Even when using Robotium my experience from several large Android projects is that writing functional testing in Java is just wrong. Over time, the ever growing test suite becomes takes more and more resources to maintain mainly because the readability goes down. But hey! Why wouldn&rsquo;t it be like that? That is exactly the same experience we had when writing functional test for websites!</p> <p>Calabash uses Robotium as a library to make the interaction with the tested app as robust as possible while letting the developer or tester write precise and clean test that are easy to maintain.</p> <p>And that&rsquo;s why you should give <a href="http://github.com/calabash/calabash-android">Calabash Android</a> a try.</p> <h2>Testing Hybrid Apps</h2> <p>If you are using Appcelerator, PhoneGap, Sencha Touch or any of the other frameworks for creating <em>hybrid apps</em>. You should really take a look at Calabash. By using the same Cucumber interface as for a native app you can test HTML 5 part of your application. Testing webviews has not been posible with the currently available test frameworks. But with Calabash you can!</p> <h2>Questions</h2> <p>Let me know at jonas@lesspainful.com or <a href="https://twitter.com/#!/jonasmaturana">@jonasmaturana</a>.</p> Calabash http://blog.lesspainful.com/2012/03/07/Calabash Wed, 07 Mar 2012 00:00:00 -0800 karl@lesspainful.com (Karl Krukow) http://blog.lesspainful.com/2012/03/07/Calabash <h2>Calabash: Functional Testing for Mobile Apps</h2> <p>Jonas and I are proud to release Calabash, a new functional testing tool for Android and iOS mobile apps based on <a href="http://cukes.info">Cucumber</a>. LessPainful has been developing Calabash over the last year working to improve its expressive power, simplicity and stability. Calabash was born out of a need for device automation and test execution at <a href="http://www.lesspainful.com">LessPainful</a>, but as of today it is released as open source to the general public: <a href="http://github.com/calabash">http://github.com/calabash</a>.</p> <h3>The short story</h3> <p>The following section, <em>Introducing Calabash</em>, is intended to describe Calabash for people who don&rsquo;t already know Cucumber, or who haven&rsquo;t been looking at functional testing for mobile apps. If this doesn&rsquo;t apply to you, you can go to the <a href="#rationale">Rationale and Benefits</a> section &ndash; otherwise just continue reading :)</p> <h3>Introducing Calabash</h3> <p>Calabash consists of two libraries <a href="http://github.com/calabash/calabash-android">calabash-android</a> and <a href="http://github.com/calabash/calabash-ios">calabash-ios</a>. As you can imagine, calabash-android is the automation and testing library for Android, and similarly calabash-ios is for iOS.</p> <p>Calabash-iOS and Calabash-Android are the underlying low-level libraries that empower the Cucumber tool to run automated functional tests on Android and iOS phones and tablets as well as on simulators. These low-level libraries enable QA, business staff and developers to work at a high level by writing tests in a natural language using the terms and concepts of their business domain. For example, here is part of a test written with Calabash.</p> <pre><code>Feature: Rating a stand Scenario: Find and rate a stand from the list Given I am on the List Then I should see a "rating" button And I should not see "Dixie Burger &amp; Gumbo Soup" And take picture Then I touch the "rating" button And I should see "Dixie Burger &amp; Gumbo Soup" And take picture When I touch "Dixie Burger &amp; Gumbo Soup" Then I should see details for "Dixie Burger &amp; Gumbo Soup" When I touch the "rate_it" button Then I should see the rating panel Then I touch "star5" And I touch "rate" And take picture </code></pre> <p>If you don&rsquo;t already know <a href="http://cukes.info">Cucumber</a>, it may surprise you that this description is actually an executable test specification that is part of a test suite for an iPhone app!</p> <p>The file above is called a feature file in Cucumber and Calabash. A feature file describes the intended behaviour of the app. You can think of a feature file as an executable test specification of a use case of the app. In our example above, we have a <em>feature</em> which describes functionality for rating a food stand at <a href="http://roskilde-festival.dk/uk/">Roskilde Festival</a>. A feature consists of one or more scenarios, corresponding more or less to the possible outcomes of the use cases. In our simple example we have only one scenario the &ldquo;sunshine&rdquo; scenario where we find a stand and rate it five stars. There would usually also be scenarios testing other things, e.g., error scenarios. Finally, each scenario consists of a number of steps. The usual form of a feature is:</p> <pre><code>Feature: name... Scenario: ... Step Step ... Scenario: ... Step Step ... </code></pre> <p>In our example, each line after &ldquo;Scenario&rdquo; corresponds to a step. In calabash, a step does one of three things: makes a user action (like touch, swipe, scroll, etc.), makes an assertion (like <code>Then I should see details for ".."</code>) or takes a screen-shot. The screen-shot step takes a snapshot of how your application looks at the point in the test. Screenshots can then be inspected for graphical errors that are hard to catch using assertions. Also, comparing screenshots across many different Android or iOS devices and operating system can be really useful. This type of visual test report, is part of what the <a href="http://www.lesspainful.com">LessPainful Service</a> offers. You can see an example our feature for the Roskilde app above in the <a href="#LessPainful">LessPainful section</a>.</p> <h3>Overview: How it works</h3> <p>We&rsquo;ll describe briefly how Calabash works. You can get more details in the blog posts on <a href="http://blog.lesspainful.com/2012/03/07/Calabash-Android/">Calabash Android</a> and <a href="http://blog.lesspainful.com/2012/03/07/Calabash-iOS/">Calabash iOS</a>. You can also go straight to the sources: <a href="http://github.com/calabash/calabash-android">http://github.com/calabash/calabash-android</a>, <a href="http://github.com/calabash/calabash-ios">http://github.com/calabash/calabash-ios</a> and <a href="http://github.com/calabash/calabash-ios-server">http://github.com/calabash/calabash-ios-server</a>.</p> <p><em>Calabash iOS</em> consists of two parts: a client library written in Ruby, and <code>calabash.framework</code>, a server framework written in Objective-C (a Clojure/JVM version of the client is coming too). To use calabash you make a special test target in XCode that links with <code>calabash.framework</code>. The application is otherwise unchanged. The server framework will start an HTTP server inside your app that listens for requests from the client library.</p> <p>The cucumber tool executes your feature files which contain steps that are defined either in <em>predefined</em> or <em>custom</em> (user defined) steps definitions. Custom steps are written using the API that the client library exposes. The API methods make HTTP requests to the server, which does things like finding components in the UI and taking actions on them. Here is an illustration:</p> <p><img src="http://blog.lesspainful.com/img/calabash-ios.png" alt="Calabash-iOS architecture" /></p> <p><a href="http://github.com/calabash/calabash-android"><em>Calabash Android</em></a> is slightly different even though the idea is much the same. You can read about the architecture of Calabash Android <a href="http://blog.lesspainful.com/2012/03/07/Calabash-Android/">here</a>. The greatest benefit of the different architecture is that you can test your Android app without making any changes to the app.</p> <p><a name="rationale"></a></p> <h3>Rationale and Benefits</h3> <p>Why create a new open source functional test library? There are several reasons.</p> <dl> <dt>Uniform interface across platforms</dt> <dd>We wanted a single interface for specifying the behaviour of mobile apps across platforms. Many companies are creating the same app (or <em>almost</em> the same app) for both iOS and Android, and pay double costs when it comes to testing. With Calabash, you have the option of maintaining only one feature file per app use-case, even if you are developing for both Android and iOS. The platform or app differences can be factored out into so-called <em>step definitions</em> which are different per platform. (If you're thinking Windows Phone? Then, yes, it is an option, but we haven't gotten round to it yet ;) </dd> <dt>Cucumber</dt> <dd>We wanted a high-level, domain-centric language for specification. The Cucumber technology gives us this. A Cucumber feature file can be written by QA, domain experts or developers. Developers or technical test staff can then write step definitions to realize the steps on each platform (possibly using one of the many predefined steps or APIs).</dd> <dt>Authenticity</dt> <dd>We wanted a test automation technology that is as authentic as possible. Test must be able to run equally well on physical, non-jailbroken devices as on simulators. The <a href="#LessPainful">LessPainful Service</a> takes this to the next level, by providing a test execution environment for running tests concurrently on many different devices (we even do <a href="">rotation using little robots!</a>). </dd> <dt>Expressive power</dt> <dd>There are some cool functional testing technologies out there already (like Robotium, Frank, NativeDriver, KIF, Zucchini and UIAutomation). However, in our opinion each of them have advantages and disadvantages, and none of them fulfilled our needs completely (see details in the blog posts <a href="#">Calabash Android</a> and <a href="#">Calabash iOS</a>). We wanted a technology with expressive power: support for complex gestures (swipes, pinch, etc), embedded webviews, rotation, backgrounding ... all while running on non-jailbroken devices. </dd> <dt>Extensibility and Community</dt> <dd>This is part of the reason why we are open sourcing Calabash. We want you to test your apps and ship better quality. We want Calabash users to be able to extend Calabash itself, and we want to build an open source community that is enthusiastic about the technology. </dd> </dl> <p><a name="LessPainful"></a></p> <h3>LessPainful</h3> <p>What is the role of <a href="http://www.lesspainful.com">LessPainful</a> in regard to Calabash, and what services do we provide?</p> <p>LessPainful is the creator of Calabash: we are its core committers and we are dedicated to continuously improving it. Our business model consists of two offerings:</p> <ul> <li><p>We offer commercial support, training and consulting on automated testing of mobile apps. We can also help setup advanced continuous integration build environments on iOS and Android.</p></li> <li><p>We provides a test execution service which runs Calabash tests &ldquo;in the cloud&rdquo;. The service automates running tests concurrently on several physical, non-jailbroken Android and iOS phones and tablets. We support several operating system versions, as well as device language and regional settings.</p></li> </ul> <p>The LessPainful service provides visual test reports. This lets you easily compare test results and the visual appearance of your app across different devices. Here is an example test report from our example &ldquo;food stand&rdquo; app:</p> <p><a href="http://blog.lesspainful.com/img/test_report_overview.png"> <img src="http://blog.lesspainful.com/img/test_report_large.png" title="Test report overview" alt="Test report overview"> </a></p> <p>The LessPainful Service is designed to support continuous integration by providing a web service for running tests with every commit or on a daily basis.</p> <p>Here is part of an Android test running on &hellip; different models!</p> <p><a href="http://blog.lesspainful.com/img/android_test_report_overview.png"> <img src="http://blog.lesspainful.com/img/android_test_report_large.png" title="Android test report overview" alt="Android test report overview"> </a></p>