XCode4 Unit Testing and UIAutomation
Asked Answered
D

1

8

I'm looking to set up testing at my company, but I'm a little fuzzy on the best way to start.

I know that I can use a framework for unit testing, such as OCUnit, GHUnit or SenTestingKit... so far so good. I can make a target which logic tests my project, using Mock objects etc.

I'm also aware of using UIAutomation and javascript to drive and test the GUI.

So, now if I implement a fairly complex GUI feature, I would like to logic test my code and also test the GUI using UIAutomation. How do I combine these two methodologies, or are they to be treated separately, in which case am I to assume that I need to write two sets of tests in two different languages to fully test one feature?

On a side-note, if anybody can provide good links for advice on beginning testing on an already mature and not-so-modular codebase, that would be much appreciated.

Thanks!

Dendroid answered 31/3, 2011 at 17:14 Comment(0)
P
4

UIAutomation is JavaScript based. Test cases are collections of JavaScript files, which are later executed by Instruments.

Yes you have to do that seperately:

  1. It is a complete different language (JS)
  2. It is not executed on Xcode-Build but by Instruments
  3. GUI tests have a different test scope from unit or logic test. Even if there are some similarities with logic tests. It is also tested, if the GUI "behaves" correctly.

This video might help you. Take an hour and afterwards you should be able to decide on your own (the UIAutomation session).

http://developer.apple.com/videos/wwdc/2010/

By the way: There is no satisfying way to automate UIAutomation tests at the moment (For logic and unit tests, there are some). For example to combine them with Continuous Code Integration. There are discussions about that, but I have not seen a solution so far. All in all you can play a little with that, but for serious testing UIAutomation is still not applicable:

  1. No test automation
  2. No separation of test cases. If one case fails within your choreography, all following test might be useless.
Priggery answered 4/4, 2011 at 9:56 Comment(2)
For simple separation of test cases you can use test() function from tuneup library by Alex Volmer: github.com/alexvollmer/tuneup_jsHyaloplasm
I just read your answer here. Do you know if Apple improved UIAutomation with iOS5? I hear rumours about it but since Apples documentation on UIAutomation is so sparse, I can't find any other information about that topic.Harragan

© 2022 - 2024 — McMap. All rights reserved.