Code completion does not works in Instruments UIAutomation script editor - instruments

In only one place in apple docs there is a statement that instruments in 4.2 supports code completion in script editor of UIAutomation. But it doesn't works for me. Is there anything i can do to make it work?

Related

Can Xcode 7 UI Testing be used for app file alone, without its code?

I have a few app/ipa files. Using instruments ui automation i could perform actions using a js file and a terminal command. Did nt need the code/project of app file. But from Xcode 7 onwards UI Automation is deprecated. And apple have brought in UI testing. With the limited tutorials available in internet I could understand that UI testing can be implemented only on an Xcode project. It cannot be run in an pp file individually. Please do correct me if my understanding is wrong. And guide me on how to do it.
Thanks in advance :-)
Don't know exactly how you can write UI testing for APP/IPA files.
But in the sense of code needed, I would rather say no. As the UI testing uses view hierarchy to find the UI Elements and perform actions, e.g. app.buttons["Hi"].tap().

AppCode + swift - no code completion and no quick documentation

Do anyone know how to enable code completion and quick documentation in AppCode(3.1.1) for swift?
I have updated Xcode I've downloaded documentation in Xcode preferences.
I set correct path to Xcode in my AppCode but still I got no support in AppCode regarding to completion and quick documentation.
This support is in XCode but I am java dev so for me better thing is to use Jetbrains tool instead of using Apple one.
Project that I've opened in AppCode was created in XCode.
I've downloaded this documentation in XCode.
I've searched a lot in the net but there are only slogans about features of AppCode
can do that this, is doing this and that
Only one thing related to path to XCode I found in this property
but none of those I can see... I believe that I haven't enabled it yet.
For me AppCode is more user friently tool because like I said I am used to Intellij for Java development and I am trying to use this tool because it is quicker for me to work with sth that I've used to than sth that is completly new for me(conceptually - XCode).
Do you have any advices about that?
I asked my quesetion to AppCode support. They responded:
Rafal, Your configuration seems correct. Please see comments
below: 1) regarding code completion in Swift - we have part of work
done in that area, and part of tasks still in progress. Can you share
a code snippet where you experience issues with completion? 2)
regarding quick documentation - this feature is not yet ready for
Swift. You can track its progress here.
This mean that I can not expect from AppCode features that was advertised in terms of swift language.

iOS8 - is there an example of UIAutomation framework from code?

I've been reading about UI automation using instruments, and the old documentation suggested that this is done using a javascript library to access frontmost app, then access UI view hierarchy.
I see that an iOS8 device has "Enable UI automation" option in the developer menu in settings. I also see that there's some documentation on the UIAutomation framework in iOS8, which seems to me like it allows to do UIAutomation from code.
Are there examples of using iOS8 UIAutomation framework from code that I can look at to understand if this is the framework for me?
I see this screen when looking for the info on UIAutomation framework, and I think it confused me into thinking that it is available in Obj-c or Swift, because of buttons on top. Can someone confirm that this framework is NOT available in either swift or Obj-c and is still a javascript framework?
.
I believe UIAutomation is still a JavaScript only testing framework. We would have heard otherwise at WWDC or in the release notes, if any other language was supported.
Concrete evidence of this however, is that the "Automation" Instrument used when profiling an app has no language drop downs to indicate another language is possible (like say, you do when creating a new class in Xcode and there's a drop-down for Swift and Objective-C).
If you use the automatic recording functionality built into the Automation Instrument, the code you see is JavaScript. The lack of options to select another language is telling. Instruments did get a minor visual tweak with Xcode 6 too, and this fact did not change.
The UIAutomation framework, sadly doesn't seem to get a lot of love of late (not much of anything has changed since the release in 2010 with iOS4, leading some to speculate there's a major revamp in the works or it's being forgotten).
To see what JavaScript code looks like that's aimed at writing tests for iOS, check out Alex Vollmer's Tuneup JS library: http://www.tuneupjs.org. His library provides a higher level abstraction, while still in JavaScript, over Apple's UIAutomation JavaScript classes.
He has a sample project linked there that runs tests on Apple's own UICatalog example application.
Using a library like Tuneup JS is a better way to go than the more primitive JavaScript classes that Apple provides, which are really just a starting point.
You should look into Subliminal. It's a testing framework which is built on top of UIAutomation that allows you write your tests in Objective C or Swift.
https://github.com/inkling/Subliminal
We have UIAutomation working in iOS 8 using the Illuminator framework (which I wrote), and use it in our CI. It is a set of extensions to the Javascript that UIAutomation provides.
Currently, Javascript is the only language for UIAutomation that Apple supports.

How should unit testing be done for gestures in iOS?

I am confused how unit testing for gestures should be done in iOS. In my application, panning a scrollview triggers an event handler that then does some stuff. When unit testing this am I supposed to:
Call the event handler directly and check to see if it does what its supposed to
Simulate the panning with some UI automation testing framework, check to see if the event handler is called, and then finally see if its the desired outcome
I would not call the eventhandler directly but instead use test frameworks doing the gestures for you.
The Apple Framework is UIAutomation - you can code your UITests via javascript just with instruments and even test your code immediately. Unfortunately it doesn't integrate well with hudson / jenkins because command line support is not really good.
What I am using in one of my projects is KIF - it works very well on you CI Server and you can code your Tests with xcode and objective-c

Is there any way to test the code coverage of UIAutomation tests?

I am using UIAutomation to test an app, and I would like to find out my code coverage. But since javascript has no preprocessor, that means that gcov and similar are not an option. Has anyone come up with a solution for this?
For Xcode version 4.5 and newer:
Set the “Generate Test Coverage Files” build setting to Yes.
Set the “Instrument Program Flow” build setting to Yes.
This will generate code coverage files every time you run your application in the simulator and exit the application. A detailed explanation of these two steps can be found at the beginning of http://qualitycoding.org/xcode-code-coverage/.
For any unit tests, code coverage files will be generated every time you hit the test button and the tests complete. For UIAutomation, it is a little bit more tricky. You have to ensure the application exits at the conclusion of your tests. The easiest way I found to do this is to turn off multitasking. Add UIApplicationExitsOnSuspend in your MyAppName-Info.plist file and set this option to 'YES'. Run your UI automation test and at the end of it you can exit the app either by manually pressing the home button in the simulator or using the UIATarget.localTarget().deactivateAppForDuration() method.
Note: if your app has any UI Automation tests that rely on the deactivateAppForDuration() method, the tests will terminate upon running the command.
Code Coverage is only used for Unit Testing, there is no Code Coverage for UIAutomation because there is no way to tell how many elements on screen has been "touched" by UIAutoamtion

Resources