Saturday, 30 June 2012

XCode 4.3 and Jenkins Code Test Coverage Updated

Since I wrote this post, XCode has been updated somewhat, more concise xcodebuild commands can be found here:

Another trip to the US under my belt.  That makes five trips in the last twelve months.  The only thing I'll say on the matter is that flying to and from JFK-LHR is so much easier than flying PDX-SEATAC-LHR.  Five and a half hours on the way back is just a ridiculous fast flight time to get thousands of miles across the Atlantic.  That coupled with Silver BA Executive Club, almost guaranteed upgrades to Club on at least one leg of each flight makes the whole business almost bearable.  The only problem, of course, is that if the ride's bumpy it's bumpy for everyone from Cattle to First.


So, XCode 4.3 makes the generation of code coverage files so much easier and this updates my previous post on the topic.  Specifically, this is geared towards doing CI builds of XCode projects from the command line.


1. Make sure you have a Test target set up in your project
2. Select it from your project settings TARGETS list
3. Go "Build Settings"
4. Set "Generate Test Coverage Files" and "Instrument Program Flow" to "Yes"

5. Optional - I don't use the "Test After Build" project setting in my main project targe to trigger the tests as I only want code coverage running on my central CI due to my desire to integrate exclusively with Cobertura.
Make sure that your CI build has the following command/s in it:

# Build and test
xcodebuild -sdk iphonesimulator -project MyProject.xcodeproj -target MyProjectTests -configuration Debug clean build TEST_AFTER_BUILD=YES

# Generate code coverage report.
/path/to/gcovr -r $ROOT --exclude '.*Developer.*' --exclude '.*MyProjectTests.*' --xml > MyProject/coverage.xml

The final bit is my hook in for GCOVR to generate Cobertura reports.

Wednesday, 9 May 2012

Debugging Android Emulator HTTP/S Traffic

The project that I am involved in at work is very network centric and I found my team having to support a third party using the Android SDK to develop an application that used the services exposed by my project.  One of the most important tasks anyone on my team can do is debug the network requests being sent by the third party application to the network services.

The Android Emulator is not the friendliest in the universe.  But..

Download Charles - A very useful tool (for OSX)

Using Charles (I have a Mac)
1. Go - Proxy -> Proxy Settings -> Enable Transparent HTTP Proxying
2. Proxy -> Proxy Settings -> SSL -> Enable SSL Proxying (if that's what you need)
3. Proxy -> Proxy Settings -> SSL -> Add : Your service end point here!
4. Help -> Local IP Address : Write this down

From the Emulator
1. Open a Web Browser -> -> Save to Device -> Set up PIN (if you're doing SSL debugging)
2. Settings -> Wireless & Networks (Maybe -> More) -> Mobile Networks -> Access Point Names -> TelKila -> Proxy : The IP Address you wrote down
3. Settings -> Wireless & Networks (Maybe -> More) -> Mobile Networks -> Access Point Names -> TelKila -> Port : 8888 (unless you've changed the default port for Charles)
All Set!