Monday, August 3, 2009

 

if you love some source code, set it free

So I have gone and

To be honest I would have liked another few days for cleanup and further testing, but I've gone and gotten a real job (iPhone app development, again) that will occupy me for at least a couple of months, so I had to hurry things up. I apologize for the ugliness of the code.

Some of that ugliness is due to its extremely crude testing framework. Unit testing, the panacea of modern software development, is bizarrely difficult to integrate with the iPhone SDK. There are various tools to help you - one created by Google - but they're all far more complex and kludgy than I'd like, especially compared to the elegant joy that is GAEUnit.

It turns out, however, that it is possible to seamlessly integrate unit tests and test-driven development into iPhone development with XCode. There are a few caveats, but overall, these instructions work very well, if you follow them very carefully.

The caveat is that you can only run the unit tests on an actual physical device, not in the simulator. Now, in some ways this is actually a bonus - you avoid the "but it works in the simulator!" pitfall, and I have learned that the only way to get a feel for what your UI should be is to work on a real iPhone or iPod Touch, the simulator is disastrously misleading - but it does mean that you'll have to go ahead and shell out the $100 to join the iPhone Developer Program so that you can generate the certificates needed to sign your app and install it on your device.

Which in turn is a bit of a hassle. But it's a necessary hassle, and one you should get out of the way as soon as possible. "Build early, build often," is a motto that has served me well for many years.

The device-testing is also limited in that you have to specifically select a test target, so you can't automatically run your unit tests every time you build your app. But as long as you remember to unit-test at least daily, and immediately after making major changes, I can't see this as that big a shortcoming.

Here's some code to run tests in their own separate database, so that you don't pollute your application's data.

Your test case's .h file looks something like this:

// Dependent unit tests mean unit test code depends on an application to be injected into.
// Setting this to 0 means the unit test code is designed to be linked into an independent executable.
#define USE_DEPENDENT_UNIT_TEST 1

#import <SenTestingKit/SenTestingKit.h>
#import <UIKit/UIKit.h>
#import "MyAppDelegate.h"


@interface MyTestCase : SenTestCase {
NSManagedObjectContext *context;
}

@end


and its .m:


-(void) setUp {
MyAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
NSURL *storeUrl = [NSURL fileURLWithPath: [[appDelegate applicationDocumentsDirectory] stringByAppendingPathComponent: @"MyAppTest.sqlite"]];

NSError *error;
NSPersistentStoreCoordinator *persistentStoreCoordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel: [appDelegate managedObjectModel]];
if (![persistentStoreCoordinator addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeUrl options:nil error:&error]) {
// Handle error
NSLog(@"Error creating persistent store MyAppTest.sqlite %@, %@", error, [error userInfo]);
}
context = [[NSManagedObjectContext alloc] init];
[context setPersistentStoreCoordinator: persistentStoreCoordinator];
}

-(void) tearDown {
[context release];
}

Labels: , , , , ,


Comments:
http://jlongster.com/blog/2009/07/5/remotely-debugging-iphone-scheme/ looks very exciting
 

Thanks for sharing this informative content.,
Leanpitch provides online training in Scrum Master Certification during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSM Certification Workshop in different cities.
CSM online

CSM online certification
 
Thanks for sharing this informative content.,
Leanpitch provides online training in Scrum Master Certification during this lockdown period everyone can use it wisely.
Join Leanpitch 2 Days CSM Certification Workshop in different cities.

CSM training online

Scrum master training online
 
The article discusses the process of releasing an open-source iPhone app, highlighting challenges and opportunities. It highlights the importance of unit testing, the need for early testing and certification, and the importance of maintaining clean data. The author's candid approach and willingness to share experiences are commendable. Abogada para Camiones Accident
 
estate litigation lawyer
If You Love Some Source Code, Set It Free is a book that delves into the philosophy behind open-source software, presenting a compelling argument for its power and positive impact on innovation and collaboration. The author's passion for the subject is evident, and the book challenges traditional notions of proprietary code. It is highly recommended for anyone in the software development industry, as it provides practical insights and real-world examples that demonstrate the power of collaboration. The book is a breath of fresh air in the world of software development, with its enthusiasm for open-source software and practical insights providing a fresh perspective on the industry. The book serves as a call to action for developers to embrace the power of sharing and collaboration, making it a must-read for anyone interested in the future of technology. The book is a must-read for anyone interested in the future of technology.
 
The phrase "set it free if you love some source code" is applied to coding and open source, suggesting that releasing code allows it to grow and improve, while if it doesn't, it contributes to the community and serves the greater good criminal defense lawyer alexandria va.
 
Source code is the backbone of any software project, providing the education needed for the program to work. Understanding its complications is essential for any developer. If you're looking into business dissertation topics
, exploring the economic impact of open source software on the tech industry. It is a fascinating area with a lot of potential for in-depth study and analysis.

 

Post a Comment

Subscribe to Post Comments [Atom]





<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]