|
UsingBromine
learn how to install and use Bromine
Phase-Deploy Using BromineIntroductionBromine will run your application on simulator executing a user-defined list of commands that will manipulate and verify application status. Your 'screens' will be represented as XML so your commands will be able to access you view through XPath. Installing Bromine
#import "MyAppDelegate.h"
#ifdef BROMINE_ENABLED
#import "ScriptRunner.h"
#endif
@implementation MyAppDelegate
...
- (void)applicationDidFinishLaunching:(UIApplication *)application {
...
#ifdef BROMINE_ENABLED
[[[ScriptRunner alloc] init] autorelease];
#endif
}
Writing testsOnce you created TestScript.plist file you'll be able to start testing your application. Your test script source code should look like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <array> <dict> <key>command</key> <string>waitForElement</string> <key>viewXPath</key> <string>//UINavigationItemView[title="UICatalog"]</string> </dict> <dict> <key>command</key> <string>simulateTouch</string> <key>viewXPath</key> <string>//UITableViewCell[text="TextFields"]</string> </dict> <dict> <key>command</key> <string>waitForElement</string> <key>viewXPath</key> <string>//UINavigationItemView[title="TextFields"]</string> </dict> <dict> <key>command</key> <string>simulateTouch</string> <key>viewXPath</key> <string>//UINavigationButton[title="Edit"]</string> </dict> <dict> <key>command</key> <string>setText</string> <key>viewXPath</key> <string>/./descendant::UITextField[1]</string> <key>text</key> <string>text 1</string> </dict> <dict> <key>command</key> <string>pause</string> <key>seconds</key> <string>9</string> </dict> <dict> <key>command</key> <string>outputView</string> </dict> </array> </plist> If you're not familiarized with plists files, this represents an array of dictionaries and, in this case, eac dictionary represents a command to be executed against your applications. The above example should do the following steps:
"Oh, this seems pretty easy... to you. How can I write my own tests?"Ok, ok... you'll be able to write your own tests as soon as you find the following 2 missing pieces. XML representantionBromine will descript your windows and views as a single - and probably huge - XML structure. How can I get this XML?Through the outputView command! You can use it anytime during the test process to obtain a "snapshot" of avaiable views. Those views should be the ones you'll may execute commands on. You can also save your XML directly to a file so you'll be able to manipulate it in special editors. Just add outputPath parameter with the file path to the outputView command. Remember: Not only UIView is a view. All of its descendants are views to like UIButton, UITextField, UITableView, etc. Now that you know "who" your views are, you must find a way to "contact" them. XPathXPath is a language for finding information in an XML document. You'll find a nice tutorial on W3Schools - XPath Tutorial. Now you can do the magic. Get your application XML, define XPath sentence for the desired views and execute your commands on them. Will can take a look at the AvailableCommands list Nothing like a good exampleI know it's pretty boring read all the stuff above. If you feel like skipping the reading and seeing Bromine in action, just check out the UICatalog sample (http://bromine.googlecode.com/svn/samples/UICatalog). Don't forget to leave console window open so you can watch your commands' results. Please, contributeNo.. not asking for money... There are many possible features to be improved or added to Bromine. Feel free to notify bugs, make suggestions or critics and, even better, send patches! |
Is this project still active (or did it mature sufficiently)? We are now into iOS 4, and I don't see much activity here - just wondering if there is any chance this will work with iOS 4 or if I need to look elsewhere. Thanks.