-
Notifications
You must be signed in to change notification settings - Fork 12
Customize Infinity Test
Infinity Test provides some cool features and it's possible to setup notifications, rubies, test_framework and much more.
Photo taken in this site
- Let's go!
You customize infinity test creating and setting a .infinity_test file your project root or home directory ( ./.infinity_test or ~/.infinity_test ) When project configuration files exists, the project file will override user home configuration file.
The Infinity uses the Awesome RVM to run.
Before anything install the RVM. See RVM Installation Instructions.
To run with many rubies just add the following to your .infinity_test file:
infinity_test do
use :rubies => %w(1.8.7 ree 1.9.2 jruby)
end
Then the infinity_test will run all the tests in 1.8.7, ree, 1.9.2 and jruby in Test::Unit.
If you want to run in gemset you can do too :) :
infinity_test do
use :rubies => %w(1.8.7@past ree@for_the_win 1.9.2@my_precious jruby@yeah)
end
Then the infinity_test will run all the tests in 1.8.7@past, ree@for_the_win, 1.9.2@my_precious, jruby@yeah gemsets in Test::Unit.
If you want to set a gemset to all the rubies you can do too :) :
infinity_test do
use :rubies => %w(1.8.7 ree 1.9.2), :gemset => 'my_gem_set', :test_framework => :rspec
end
Then the infinity_test will run all the tests in 1.8.7@my_gem_set, ree@my_gem_set, 1.9.2@my_gem_set with Rspec
Please make sure that you have all installed gems that you need in all the rubies that you want.
Test Unit is the default test framework for Infinity Test. If you setup nothing, the Infinity Test will use it.
If you want to use Rspec in just the current ruby, just add the following to your .infinity_test file:
infinity_test do
use :test_framework => :rspec
end
Or if you want to use Rspec with many rubies, just add the following to your .infinity_test file:
infinity_test do
use :test_framework => :rspec, :rubies => ['1.8.7', '1.9.2']
end
Then the infinity_test will run all the specs in 1.8.7 and 1.9.2 in Rspec
Make sure that you have Rspec installed in all rubies that you want to use! And the Infinity Test is compatible with Rspec 2.0.0 and Rspec 1.3.0.
InfinityTest support Bacon too - for more information see - http://github.com/chneukirchen/bacon
infinity_test --bacon --rubies=1.9.2,ree
If you want run with Bacon just add :test_framework => :bacon to .infinity_test file:
infinity_test do
use :test_framework => :bacon
end
InfinityTest support Rails now:
infinity_test --rails
Or in the .infinity_test file:
infinity_test do
use :app_framework => :rails
end
The default Application is Rubygems. If you setup nothing InfinityTest will use it.
If you are developing on a Mac, Growl is a popular desktop notification for OS X. First Download the Growl http://growl.info/index.php and install it. Then you must install the growlnotify.
To enable growl just add the following line to your .infinity_test file:
# ˜/.infinity_test or ./.infinity_test
infinity_test do
notifications :growl
end
If you are running on Linux and use the Gnome desktop, you need to have libnotify binaries installed and a program named notify-send in your PATH. For most Linux distributions this simply means that you should install the libnotify-bin package:
sudo apt-get install libnotify-bin
After this just add the following to your .infinity_test file:
# ˜/.infinity_test or ./.infinity_test
infinity_test do
notifications :lib_notify
end
The Infinity Test provide some images to show after the test run.
The name conventions for the image files are:
-
sucess (.png or .gif or .jpg ... etc) when all the tests pass :)
-
pending (.png or .gif or .jpg ... etc) when have pending tests
-
failure (.png or .gif or .jpg ... etc) when have failure/errors tests
All the images you can see here => IMAGES
To set the default images, you just only set the notifications framework and Infinity test show you this images AUTOMATIC.
The default images that Infinity Test will show to you:
If you want to display a images in another folder just add the directory name in symbol.
Example:
I want to show images in the Mario Bros folder http://github.com/tomas-stefano/infinity_test/tree/master/images/mario_bros/ just add following in the .infinity_test file:
# ˜/.infinity_test or ./.infinity_test
infinity_test do
notifications :growl do
show_images :mode => :mario_bros
end
end
To see all images that you can use see here: => http://github.com/tomas-stefano/infinity_test/tree/master/images
Then the infinity_test will show the sucess.png, failure.png and pending.png images in the mario_bros folder. The images in mario_bros folder are:
If you want another directory (Your custom images) just add:
infinity_test do
notifications :growl do
show_images :mode => :my_dir_images
end
end
Or:
infinity_test do
notifications :growl do
show_images :mode => 'path/to/my/images/dir/'
end
end
If you want setup by hand the images you can too. Just add the following:
infinity_test do
notifications :growl do
show_images :sucess => 'path/to/image/sucess.png', :failure => 'path/image/failure.png', :pending => 'another/pending.jpg'
end
end
You can set callbacks in infinity_test. Supposed you want before the tests run, you want to clear the terminal.
Simple :), add the following to your .infinity_test:
infinity_test do
before_run do
clear :terminal
end
end
You can also set after callbacks too:
infinity_test do
after_run do
# some code ...
end
end
After version 0.2.0, you can do callbacks for each ruby:
infinity_test do
before(:each_ruby) do |environment|
environment.system('rake compile') # will run rake compile in each ruby that you specified
... some other code
end
after(:each_ruby) do |environment|
... some other code
end
end
Note: The environment object is a instance of RVM::Environment. The Infinity uses RVM Ruby API. For more information see the source code your ~/.rvm/lib directory.
This example tell to InfinityTest run all the tests when ruby_file.rb is changed This basic DSL you will put in the infinity_test file:
heuristics do
add('^my_dir/ruby_file.rb') do |file|
run :all => :tests
end
end
If you want run only the similar test file you can do too:
heuristics do
add('some_file.rb') do |file|
run :test_for => file
end
end
If you want run only the similar test in some dir, you can do too:
heuristics do
add('some_file.rb') do |file|
run :test_for => file, :in_dir => :models
end
end
If you want run all tests in a particular dir, you can do too:
heuristics do
add('some_file.rb') do |file|
run :all => :tests, :in_dir => :controllers
end
end
You can pass an array of dirs too (w00t!!):
heuristics do
add('some_file.rb') do |file|
run :all => :tests, :in_dir => [:controllers, :models]
end
end
Need to support other type that InfinityTest won't do it? Talk to me and let me know that I'll hear you.
If you want use with ruby extension you can do with the #heuristics method:
heuristics do
add('^ext/*/(*.)\.c') do |file|
run :all => :tests
end
end
An real example you can see here: https://github.com/tomas-stefano/relation/blob/master/ruby_wrapper/.infinity_test
The InfinityTest try to discover If the user have a Gemfile in the project root and if Gemfile exists InfinityTest will run with "bundle exec #{command}" else will run "command" normally.
Obs.: In any case, you don't want this "magic" just run infinity_test with --skip-bundler flag. Or write this in .infinity_test file:
# ~/.infinity_test or ./.infinity_test
infinity_test do
skip_bundler!
end
The Infinity Test don't print the commands(Verbose Mode). To print the command you want to set verbose mode!
infinity_test do
use :verbose => true
end
-
Possible to setup the lib pattern, test pattern.
# ~/.infinity_test or ./.infinity_test infinity_test do replace_patterns do |application| application.test_framework.test_directory_pattern = "^my_unusual_spec_directory/unit/(.*)_spec.rb" application.test_framework.test_pattern = "my_unusual_spec_directory/unit/*_spec.rb" application.library_directory_pattern = '^my_unusual_lib_directory/*/(.*).rb' end end
OBS.: The #before_env methods is an alias to #replace_patterns method
I hope that you like! :)