Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode4 Unit Testing and UIAutomation

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!

like image 664
Sam Avatar asked Mar 31 '11 17:03

Sam


People also ask

What is difference between unit tests and UI test in Xcode?

The really short version is that unit tests have access to the code in your app (or whatever kind of module you are building) and UI tests do not have access to the code. A unit test only tests one single class per test.

How do I test UI in Xcode?

If your app doesn't already have a UI testing target, all you have to do to add one is to go to File > New > Target.. in Xcode and select a “UI testing bundle”.

What is unit testing in UI?

Unit Testing is a type of software testing where individual units or components of a software are tested. The purpose is to validate that each unit of the software code performs as expected. Unit Testing is done during the development (coding phase) of an application by the developers.


1 Answers

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.
like image 67
Rene Berlin Avatar answered Sep 25 '22 20:09

Rene Berlin