iOS CI: How to run calabash tests using bots? - ios

I am using Calabash to perform UI tests in my iOS app.
Calabash is chosen because tests could be written using Gherkin-style and I can use RubyMine.
Good things: any time during writing gherkin scenarios I can easily get a list of already implemented functions (like: When user successfully logged in) and also RubyMine will create functions for every new scenario. These are actually huge benefits.
Bad things: In addition to UI tests in Calabash I also have native unit tests which I run using bots, but I didn't figure out how run Calabash tests using bots on OS X Server.
So in ideal world I would like to have something what KIF does: bots could run UI tests and give nice OS X Server web page results, but at the same time I'd like to have all benefits of using Calabash + RubyMine
Or maybe there is a way to run calabash cucumber tests on OS X Server using bots? And I am not really comfortable using OS X Server for native unit tests and Jenkins for cucumber tests. I just want one tool do whole thing.
Any suggestions?

Create a new bot and set its Schmeme to your Calabash scheme, e.g., MyXcodeScheme-cal. Then for example add an iPhone in the testing tab as target.
But unfortunately a successful integration does not mean that the Calabash tests has passed - only that the test were executed! So the Calabash test results itself has to be investigated manually afterwards :S
:)

Related

How to write integration tests in Xcode?

There are three basic layers of testing:
Unit test — making sure each function/unit of code works as expected
Functional test — making sure units interact with each other as expected
Integration test — making sure our app integrate with other app/api/services as expected
I can handle cases 1. and 2. using Xcode's iOS Unit Testing Bundle and iOS UI Testing Bundle I don't know how to write tests from point 3.
I would like to write to tests to check if me app correctly integrate with backend, BLE device, etc.
Note that I have already written unit tests which I run using CI.
Integration test should not be run in CI because it depends on external environment. I would like to run its only manually.
How to handle it in Xcode? Second Unit Testing Target? Any advice? How are you dealing with it in yours systems?
Depending on the style of integration test that you are after you may want to use dedicated a unit or UI tests target.
From your question I'm guessing the style you want to have leans towards black box testing with other real systems. If that's the case a dedicated UI tests target would do the job.
With UI tests you can do stuff like opening other apps on the device and test how your app interacts with them. For example, this post shows how to write a UI test that uses the Messages app to test Universal Links.
I'd reach for using a dedicated unit tests target only if you need to control part of the code in your app, for example stubbing network requests. But that doesn't really fit with the definition of integration test you have given.

For mobile automation what are the advantages of Appium VS Calabash and of Calabash VS Appium?

I have used Appium in Mobile automation with IOS and Android. I wanted to know about advantages that offers Calabash and if there are common point in generated scripts of both tools?
I have followed this link : Appium VS Calabash
I have hands on in mobile automation quite a long time. let me tell my point of view on both tools.
both also have advantage and disadvantage find below:
I have used calabash and appium both for automation. Appium has more advantages than calabash.
Advantages of Appium over Calabash:
1. You can write your code in multiple language like Java,Python, C#, php etc. However, Calabash restrict to use RUBY only.
Appium comes with many predefined methods such as OpenNotification(), StartActivity(), InstallApp etc. Calabash does not provide such predefined methods.
Appium set up is very easy as compared to Calabash.
In calabash, it installs the app on the device every time you run the test. However, In appium you have a feature where in you don't need to install the app every time. It works with previously installed app on the device.
Appium works with both native and hybrid app.
There are many advantages of appium. I hope this helps.
Try them both for yourself.
I found calabash easier to get started. I had a complete user flow test working from setup to working test in Calabash in half the time it took for Appium.
I don't like using xpath. It makes tests brittle and subject to breakage if something in the layout changes. Appium requires mainly the use of xpath. Calabash allows you to drive actions and interactions through the selection of elements by their text . I prefer this because that same text is normally in the designs and/or requirements.
Some comments in other posts are not accurate. Calabash does not require the install of the app every time unless you don't look beyond the surface. There is a simple means to enable/disable it. I have logic that runs either way based on passing an argument. Calabash has more than enough existing methods to interact with your app. It has a built in debug that allows you to tinker with element interaction and those same calls can be copied and reused in your test code. Using it with getgauge.io provides reporting akin to the built in Cucumber but is easier to run multi-threaded and easier to write your feature/spec files.
Be fair to both tools and yourself. Create a simple project in each and try for yourself. Don't make a decision solely based on someone else's opinion.
There is no common part in the automation scripts since Calabash uses query for interacting elements but Appium uses selenium find functions.
The best part of the Calabash is that you can use cross-platform frameworks for automating ios and android application with same feature file and most part of automation code. However the worst part is that Calabash is Ruby only.
Look at this post for more details about the differences of Calabash and Appium.
Since you have already read the differnces , Few things to note that Calabash can also be used with Xamarin which is also a good tool to test hybrid apps and you can run the same script for ios and android apps with some minor changes.Also it has been now integrated into visual studio,so microsoft support is inevitable and some users might feel comfort factor.Lambda expressions are also a plus.A major setback with the Calabash however that it only uses ruby.
Appium on the other hand can support various languages which is plus and you can use webdriver as well.However it struggles with hybrid apps but you can overcome that functionality by using google chrome mobile view to find coordinates to click.one thing for sure is that sause labs have many bugs to fix in Appium yet.

iOS unit testing on a Mac running Mountain Lion (OS X 10.8.5)

I have an iOS project that comes from an older Xcode (4.6.3) and that did not include a test target by default, as projects in latest Xcode versions seem to include. I now have Xcode 5.1.1. on a Mac that is running OS X 10.8.5. I've reading this Apple's document regarding unit testing in Xcode, but it looks like you need OS X Mavericks, at least for installing and configuring OS X Server, don't you?
I'd appreciate some guidelines to follow to add a test target to my project and how could I integrate a testing process in my workflow if I do not have OS X Maveriks.
Thanks in advance
EDIT: Is there anyway of run tests in normal running of the app? I mean, I need to test some cases that involve the update of data at certain hours, and the update of some parameters and the GUI after that data update... how could I do this? Thanks
You need Mavricks if you wish to use the Xcode service, which is Apple's continuous integration server. You do not need Mavricks to run unit tests, however you will miss out on the pretty in-xcode reports.
Without Mavericks, you can run unit tests manually by pressing CMD+U or going to Product->Test.
You can also setup your own continuous integration service and run the unit tests with a command line script. You'll have to pick a CI server, something like Jenkins or many alternatives, and look up a how-to for that system.
Do you redirect NSLog/stderr anywhere?
I encountered this problem too with no red marks and failing test of '1 == 1'.
My app was catching NSLog calls to a file and not letting the system get them. Once I disabled the redirecting of logs freopen(filepath, "a", stderr) test started passing and green checks and red crosses appeared.
I did this for an external accessory device that hooked up through the lightning port and couldn't send the logs to the mac. You mentioned how you want to run the test during the normal running of you app, so I figured you may have saved the logs so you could read them away from you mac.

Is it possible to perform GUI testing using Xcode Unit test

I would like to perform the following iPad/iPhone testing scenario automatically:
Tap Edit box A
Type text "abcd"
Verify button B is high-lightened
I understand UIAutomation 4.0 allow you to write a simple JavaScript to perform the above steps. However, UIAutomation does not have test infrastructure ready. For example it lacks testing macros to show if any tests failed and does not have a clear way to run setup and shutdown for each test cases.
That is why I look back to XCode unit testing. Logic tests won't work for me. How about Application tests?
Basically, I am looking for something that can do GUI testing and at the same time has test infrastructure. It is even better if it can be integrated to continuous build environment.
Check out Zucchini. It's just come out and I saw a demo at a recent YOW! conference. It's basically a BDD testing framework that uses coffeescript for scripting and runs against an actual device. It's also fully runnable from CI servers which makes it perfect for agile teams.
I haven't run it myself yet, but it seems to exactly what I'm looking for and No I don't work for PlayUp :-)

Good test runner for OCUnit/XCode Unit Tests

Is there a good GUI based test runner for the OCUnit/XCode 4 unit testing frameworks? I'm looking for a redlight/greenlight type GUI, maybe something that looks like the NUnit test runner. I found OCRunner, but it looks like it hasn't been maintained since 2009. It's unfortunate, because OCRunner looks like it was exactly what I was searching for. It loads on Lion, but I can't get it to pick up my test bundle and run it.
Any suggestions for an alternative or a way to get OCRunner to run on a unit test bundle against an iOS project?
*FYI - I'm running XCode 4 with the default unit testing bundle template
You should use GHUnit.
I've also managed it to run it automatically under Jenkins with the iOS Simulator. GHUnit can also export Jenkins valid XML's (JRun).

Resources