Database Reference
In-Depth Information
Using it is very simple. Simply invoke it with a list of the source (not header) files that
you wish to have analyzed, and it will spit out the result to the command line. For
example, running it against our source tree gives results like this:
$ ./hfcca13.py `find ChatAPI -name "*.m" -print`
==============================================================
NLOC CCN token function@line@file
--------------------------------------------------------------
9 2 10 init@13@ChatAPI/ChatAPI/GoogleTalkAPI.m
6 1 4 setUp@13@ChatAPI/ChatAPITests/ChatAPITests.m
6 1 4 tearDown@20@ChatAPI/ChatAPITests/ChatAPITests.m
4 1 3 testExample@27@ChatAPI/ChatAPITests/ChatAPITests.m
--------------------------------------------------------------
2 file analyzed.
==============================================================
LOC Avg.NLOC AvgCCN Avg.ttoken function_cnt file
--------------------------------------------------------------
24 9 2 10 1 ChatAPI/ChatAPI/GoogleTalkAPI.m
33 5 1 3 3 ChatAPI/ChatAPITests/ChatAPITests.m
!!!! Warnings (CCN > 15) !!!!
==============================================================
NLOC CCN token function@file
--------------------------------------------------------------
Total warning: (0/4, 0.0%)
As you can see, we're being good little programmers, and have no methods with CCN
values above 15. The script takes a number of parameters to tweak the behavior, in-
cluding setting the warning threshold for the CCN value. At work, we've integrated
the script into our Hudson build, and the build automatically breaks if it finds values
above a certain level.
Creating UI Tests (The Old and Painful Way)
If you want to test your UI, the traditional way (at least for the last year or so) has been
to use the UIAutomation Framework. The UIAutomation Framework works in con-
junction with the Instruments tool. You create JavaScript files that can be used to access
and poke at the UI elements of the application, within some fairly restrictive bounds,
and with some nasty bugs to watch out for. I was never so happy a developer as the
day I was able to hand off test script creation to our QA team, because it was excruci-
ating work to create them.
To begin, we need to do some setup work in our project. The framework uses the
Accessibility label property of UI elements to refer to them in the JavaScript, so the first
step is to mark up the elements in Interface Builder (shown in Figure 5-6 ). However,
there's a bug that will cause everything to go pear-shaped very quickly if you ever assign
an accessibility label to a view of any kind, so you may be better off without it.
 
Search WWH ::




Custom Search