Before you will release your app to the Play Store or App Store it needs to be tested. And while we can do that manually it would be better to do that in an automated way.
Android Studio support unit testing and so does xCode. However we also have to run UI tests. Google has released the Espresso framework for this purpose. And there is Xcode 7, which also has introduced UI testing features.
But what is a smart thing to do if we want to test the same functionality for both Android and iOS? Cucumber could be the answer to that question.
Cucumber & Calabash
Cucumber is a tool that runs automated acceptance tests written in a Behaviour-Driven Development style. It describes how software should behave in plain text.
Features are being described in a feature file, like in the example shown here.
Scenario: Login Given I am on the Login Screen Then I touch the "Email" input field Then I use the keyboard and type "hello@world.nl" Then I touch the "Password" input field Then I use the keyboard and type "verysecretpassword" Then I touch "LOG IN" Then I should see "Hello world"
This is not just documentation. It can be used for automated UI tests as well.
Features are being described in a domain specific language. They describe the behaviour of software without much implementation details. So these tests can also be written by the non developing members in your team.
Calabash & some glue
Calabash is a framework that you can use for running Cucumber tests on Android and iOS apps. The framework has been created by the guys from Xamarin, which makes sense I guess, since Xamarin is a cross mobile platform solution.
There is some glue code required to actually run Cucumber tests using feature files. This glue needs to be defined in step definitions and Cucumber typically lets you write these step definitions in the Ruby language. The glue is platform specific but the feature file is not so theoretically it can be used for both the Android and the iOS version of your app.
Another cool thing about Calabash is that it allows you to run automated tests in the cloud, for example by using the services of TestDroid or the Xamarin Test Cloud.
Conclusion
Seeing Cucumber tests in action is great but it may take a while before you have setup all the things you need for it.
Behaviour Driven Development sure is an interesting approach. Using Cucumber and Calabash we can create mobile UI and acceptance tests for both Android and iOS.
The downside is that in particular Calabash does not seem to be very mature yet. The tests run slow and it takes a considerable amount of time to define them. Also the mixture of Gherkin feature files, Ruby glue and Java/Objective-C/Swift code feels weird.
On the other hand the Calabash framework is still in beta so it probably is just a matter of time before mobile behaviour driven development becomes widely adopted.
No comments:
Post a Comment