minitest-macruby provides extensions to minitest for macruby UI testing. It provides a framework to test GUI apps in a live instance. Documentation and examples are light at the moment as I’ve just thrown this together. Suggestions for extensions are very welcome!
Currently it provides the following methods in minitest’s assertions:
assert_ui_menu menu, *items
assert_ui_action obj, target, action, key = nil
assert_ui_binding item, binding_name, target, path
Here is my current macruby UI testing setup:
Has an isolate setup to pull down all my testing gems.
task build - runs xcodebuild to build a debug app
task link - runs a build and then hard links source files to build files
sets ‘backup-by-copying-when-linked to t - allowing work on hardlinked files to go unimpeded.
Sets ENV to macruby.
Sets ENV to 1.
Sets ENV and ENV with expanded paths to pick up isolated gems during test runs.
initialize hook sets the test framework to minitest and runs the link rake task.
Overrides Autotest#make_test_cmd to execute the binary directly.
sets $TESTING = ENV
applicationDidFinishLaunching requires minitest/macruby if $TESTING
needed to be tweaked to skip loading test files.
So, when I fire up autotest it will build the application and then hardlink all the original source files into the build. This allows autotest to scan the lib and test dirs but invoking the application will pick up all my changes without having to rebuild. This greatly speeds up development.
When autotest runs the application directly, it does so with MACRUBY_TESTING set in the environment. The application sees this and sets $TESTING to true and once the app is done launching, it loads minitest/macruby. That in turn loads up all the test files in the build dir and then runs the tests. Once the tests are run, it exits with the appropriate exit code depending on test results.
Provides extensions to your test cases to help test OSX GUI apps.
Still needs spit and polish.
new, open, _, close, save = find_ui_menu_items "File" assert_ui_action new, delegate, "new_document:", "n" assert_ui_action open, delegate, "open_document:", "o" assert_ui_action close, delegate, "close_document:", "w" assert_ui_binding close, :enabled, delegate, has_window
sudo gem install minitest-macruby
(The MIT License)
Copyright © Ryan Davis, seattle.rb
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.