Appium iOS code coverage - ios

I am using Appium for automation test cases in iOS project. I would like to create a report of code coverage. I have gone through appium documentation as well as on internet forums, but didnt find any way.
Is there any way to get it for iOS (Appium)?

It is not possible to do a code coverage because appium doesn't test the actual source code. Appium tests only from the UI level. You might have to manually map the functional test cases and see which all functions it get called when the test is done. But certainly there is no way to figure out like UnitTests with a report to see percent wise code covered report.

Related

How I do I automate Xamarin.iOS unit test project

How I do I automate Xamarin.iOS unit test project.
For Android, I found this link which worked fine.
https://developer.xamarin.com/guides/android/troubleshooting/questions/automate-android-nunit-test/
Is there any references like this for Xamarin.iOS too?
At the time of writing this, I don't believe what you'd like to do is possible. If I take your meaning, you'd probably like to say "Run All" with some test runner (presumably in XS or VS) and then get the results immediately, but that's not how it works with Xamarin.iOS. I'm sure you've already glanced at Xamarin's iOS testing quick-start, but if not here that is.
You have to set up a Unit Test app that uses the Touch.Unit framework, fire up the test app, and "touch" the tests you'd like to run. My experience doing this has not been so great. The runner itself seems buggy and you're limited with in what other tools you can use (e.g., mocking frameworks won't work, assertions made with Shouldly won't register). I guess it's better than nothing, though!

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.

Where to write code in Appium iOS test automation software?

I am new to automation and trying to use Appium(Mac app) for writing test scripts on iOS app.
I have managed to load my app successfully on Appium and also used Appium Inspector.
There is a Record button which records my actions in Appium inspector.
However, my question is how do I save these recorded scripts for reuse?
Secondly, I also want to manually write test scripts using Java, but currently don't know where to write code using Appium Mac app.
I have read the starter guide on Appium website and seen some videos but cannot find any app usage related information.
Any help(links, tutorial video) will be appreciated.
P.S. I do not use Selenium.
My suggestion is to not use the record feature in Appium, it's not stable and hard to maintain.
You can write your java-automation-code on Eclipse/intellij(and all java IDE)
You have a lot of information on internet, you can start here:
Appium - Git - Sample - java
Try to make it run, and take it from there.
You always can ask at discuss.appium.io and see examples.
Good luck, hope it's helps a little.
You can use any programming language supported by Appium where you feel better.
Setup environment and create test scripts. you can learn from:
Appium
Jave Sample
You can write your script in the same way as you used to right in Selenium means you can choose any IDE (in my case I'm working on Eclipse Juno) and then just pass all the capabilities if you will use TestNG framework then run as TestNG.

How to get code coverage in Xcode 6?

My tests are XCTests and I'm using Objective-C instead of Swift.
I've seen some articles that tackle the topic, but the seem focused on older versions of Xcode, for example:
Visualizing Code Coverage with Xcode
Code Coverage Fixed for Xcode 5.1
What would be the recommended approach to get code coverage on Xcode 6? Does Apple have something built in for code coverage, maybe via Xcode CI via OSX Server?
Take a look at frankencover.it
Simple script that can be run from dev's cmd-line or CI build server.
Produces console output as well as a detailed report in HTML format. This can be viewed locally or published as an artifact by the build server.
Optionally includes a checker that will 'fail' the build if required coverage is not met. (Feedback only. This is a prompt to review coverage and look for useful tests that can be added or reduce the required amount. Either option may be correct. )
Free for both commercial and open-source projects. No hosting, sponsorship or subscription required.
Usage:
FTW, it has an easy-to-remember dogue-speak-esque command line interface:
groovy http://appsquickly.github.io/frankencover.it/with --source-dir MyProject/Source
Terminal Output:
HTML Report:
We use Xcoverage for this..Check on link below, if this helps..
Xcoverage
This is an update, From Xcode 6 Apple having in-build code coverage tool, But Have a look at coverStory it is easy to configure test locally before push.
And providing a line by line coverage.

Can I integrate my UIAutomation Tests with XCode and set automitically run them every night?

I need to know if I can do Continuous Integration with XCode server. In example: set run the tests every night or when someone commit changes, and more..
I am trying to decide one iOS Ui Automation tool to integrate with my Xcode server
Thanks
There are a few problems here:
UIAutomation has no built in support in Xcode Server. I've filed bugs, I've chased down people at WWDC. Most I've ever gotten on this problem is basically "shrug." I'm not sure UIAutomation is a priority for Apple right now. So you're not going to get any official support.
As was noted, you might be able to use a trigger. The trigger won't be able to add anything to the Xcode Server report, besides possibly the error logging. But you're not going to get anything added to the nice report table.
Running on actual devices has traditionally been a problem (if you care about that.) The loading the app part has been a problem for us, but Xcode Server might be able to preload the app for you. In addition, it seems like this might have changed in the iOS 8 SDK.
There is just a lot of uncertainty around this sort of workflow. I'm hoping Apple eventually makes an announcement or adds a new tool, but the best answer I've gotten is if you want to go down this path, use UI Unit Tests. That's a shame because it requires knowledge of Obj-C or Swift, and means interacting with the app at an API level instead of an abstract level, but if you're looking for the direction Apple wants to see people go, that's it.
Edit 7/4/2015: As of WWDC 2015, there is a new UI Testing component as part of Xcode 7 that, in my experience, seems totally supported, and is promising Xcode Server support. I would very strongly recommend using that, and not using the Instruments UIAutomation tool.
With Xcode6 right around the corner they are adding some features to XCode Server specifically it looks like "Triggers" will be helpful for running iOS UIAutomation tools. Since you can run UI automation scripts from cmd line it should be possible to utilize triggers to run your scripts post builds. This along side the logic for when a bot should run will let you decide if it should be nightly or on every commit.
https://developer.apple.com/library/prerelease/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/Articles/xcode_6_0.html#//apple_ref/doc/uid/TP40014509-SW1
I wrote a framework around UIAutomation called Illuminator to handle tasks like nightly test runs, pull request tests, and other automated conveniences.
It provides a flexible and extensible command line that can execute any particular subset of tests that you'd like, and produces reports in JUnit format (used by Jenkins).

Resources