# ZenTest-4.11.0 Documentation

home | github.com/seattlerb/zentest
rdoc | docs.seattlerb.org/ZenTest

## DESCRIPTION

ZenTest provides 4 different tools: zentest, unit_diff, autotest, and multiruby.

zentest scans your target and unit-test code and writes your missing code based on simple naming rules, enabling XP at a much quicker pace. zentest only works with Ruby and Minitest or Test::Unit. There is enough evidence to show that this is still proving useful to users, so it stays.

unit_diff is a command-line filter to diff expected results from actual results and allow you to quickly see exactly what is wrong. Do note that minitest 2.2+ provides an enhanced assert_equal obviating the need for unit_diff

autotest is a continous testing facility meant to be used during development. As soon as you save a file, autotest will run the corresponding dependent tests.

multiruby runs anything you want on multiple versions of ruby. Great for compatibility checking! Use multiruby_setup to manage your installed versions.

## FEATURES

- Scans your ruby code and tests and generates missing methods for you.

- Includes a very helpful filter for Test/Spec output called unit_diff.

- Continually and intelligently test only those files you change with autotest.

- Test against multiple versions with multiruby.

- Includes a LinuxJournal article on testing with ZenTest written by Pat Eyler.

- See also: blog.zenspider.com/archives/zentest/

- See also: blog.segment7.net/articles/category/zentest

## STRATEGERY

There are two strategeries intended for ZenTest: test conformance auditing and rapid XP.

For auditing, ZenTest provides an excellent means of finding methods that have slipped through the testing process. I've run it against my own software and found I missed a lot in a well tested package. Writing those tests found 4 bugs I had no idea existed.

ZenTest can also be used to evaluate generated code and execute your tests, allowing for very rapid development of both tests and implementation.

## AUTOTEST TIPS

Setting up your project with a custom setup is easily done by creating a ".autotest" file in your project. Here is an example of adding some plugins, using minitest as your test library, and running rcov on full passes:

    require 'autotest/restart'

    Autotest.add_hook :initialize do |at|
      at.testlib = "minitest/autorun"
    end

    Autotest.add_hook :all_good do |at|
      system "rake rcov_info"
    end if ENV['RCOV']

Do note, since minitest ships with ruby19, if you want to use the latest minitest gem you need to ensure that the gem activation occurs! To do this, add the gem activation and the proper require to a separate file (like ".minitest.rb" or even a test helper if you have one) and use that for your testlib instead:

.minitest.rb:

    gem "minitest"
    require "minitest/autorun"

.autotest:

    Autotest.add_hook :initialize do |at|
      at.testlib = ".minitest"
    end

If you prefer to suffix test files with "_test.rb" (instead of the default which prefixes test files with "test_") you can change the mapping by installing the autotest-suffix plugin. To do this first install the autotest-suffix gem:

    $ gem install autotest-suffix

Then add the following to the ".autotest" file:

    require "autotest/suffix"

If you prefer minitest/spec to minitest/unit, you can still use autotest by installing the autotest-spec plugin. To do this first install the autotest-spec gem:

    $ gem install autotest-spec

Then add the following to the ".autotest" file:

    require "autotest/spec"

## SYNOPSIS

    ZenTest MyProject.rb TestMyProject.rb > missing.rb

    ./TestMyProject.rb | unit_diff

    autotest

    multiruby_setup mri:svn:current
    multiruby ./TestMyProject.rb

## Windows and Color

Read this: blog.mmediasys.com/2010/11/24/we-all-love-colors/

## REQUIREMENTS

- Ruby 1.8+, JRuby 1.1.2+, or rubinius

- A test/spec framework of your choice.

- Hoe (development)

- rubygems, 1.8+

- diff.exe on windows. Use gnuwin32.sourceforge.net/packages.html

## INSTALL

- sudo gem install ZenTest

## LICENSE

(The MIT License)

Copyright (c) Ryan Davis, Eric Hodel, 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.

## Files

- History.txt
- Manifest.txt
- README.txt
- how_to_use_zentest.txt
- example.txt

## Classes/Modules

- Autotest
- Autotest::AutoUpdate
- Autotest::Bundler
- Autotest::Isolate
- Autotest::Once
- Autotest::Preload
- Autotest::RCov
- Autotest::Restart
- Autotest::Timestamp
- FunctionalTestMatrix
- Module
- Multiruby
- UnitDiff
- ZenTest
- ZenTestMapping

## Methods

- ::action — FunctionalTestMatrix
- ::add_discovery — Autotest
- ::add_hook — Autotest
- ::autodiscover — Autotest
- ::autotest — ZenTest
- ::build_and_install — Multiruby
- ::clean — Multiruby
- ::command= — Autotest::RCov
- ::dir= — Autotest::Isolate
- ::each_scm_build_dir — Multiruby
- ::env — Multiruby
- ::fetch_tar — Multiruby
- ::fix — ZenTest
- ::glob — Autotest::Preload
- ::glob= — Autotest::Preload
- ::gnu_utils_build — Multiruby
- ::help — Multiruby
- ::in_build_dir — Multiruby
- ::in_install_dir — Multiruby
- ::in_root_dir — Multiruby
- ::in_tmp_dir — Multiruby
- ::in_versions_dir — Multiruby
- ::list — Multiruby
- ::matching_versions — Multiruby
- ::matrix — FunctionalTestMatrix
- ::merge_rubygems — Multiruby
- ::mri_latest_tag — Multiruby
- ::new — ZenTest
- ::new — Autotest
- ::options — Autotest
- ::options= — Autotest::RCov
- ::parse_options — Autotest
- ::pattern= — Autotest::RCov
- ::rake_build — Multiruby
- ::rm — Multiruby
- ::root_dir — Multiruby
- ::run — Multiruby
- ::run — Autotest
- ::runner — Autotest
- ::setup_dirs — Multiruby
- ::sleep_time= — Autotest::AutoUpdate
- ::svn_co — Multiruby
- ::tags — Multiruby
- ::unit_diff — UnitDiff
- ::update — Multiruby
- ::update_cmd= — Autotest::AutoUpdate
- ::update_rubygems — Multiruby
- ::usage — ZenTest
- ::usage_with_exit — ZenTest
- #add_exception — Autotest
- #add_mapping — Autotest
- #add_missing_method — ZenTest
- #add_sigint_handler — Autotest
- #add_sigquit_handler — Autotest
- #all_good — Autotest
- #analyze — ZenTest
- #analyze_impl — ZenTest
- #analyze_test — ZenTest
- #blur — Module
- #class_map — Autotest
- #clear_exceptions — Autotest
- #clear_mappings — Autotest
- #consolidate_failures — Autotest
- #convert_class_name — ZenTest
- #create_method — ZenTest
- #debug — Autotest
- #diff — UnitDiff
- #exceptions — Autotest
- #files_matching — Autotest
- #find_files — Autotest
- #find_files_to_test — Autotest
- #focus — Module
- #focus_re — Module
- #generate_code — ZenTest
- #get_class — ZenTest
- #get_inherited_methods_for — ZenTest
- #get_methods_for — ZenTest
- #get_to_green — Autotest
- #handle_results — Autotest
- #hook — Autotest
- #is_test_class — ZenTest
- #known_files — Autotest
- #load_file — ZenTest
- #make_test_cmd — Autotest
- #massage — UnitDiff
- #methods_and_tests — ZenTest
- #missing_methods — ZenTest
- #munge — ZenTestMapping
- #new_hash_of_arrays — Autotest
- #normal_to_test — ZenTestMapping
- #old_run_tests — Autotest
- #options — Autotest
- #parse_diff — UnitDiff
- #parse_input — UnitDiff
- #path_to_classname — Autotest
- #process_class — ZenTest
- #remove_exception — Autotest
- #remove_mapping — Autotest
- #reorder — Autotest
- #rerun_all_tests — Autotest
- #reset — Autotest
- #restart — Autotest
- #result — ZenTest
- #ruby — Autotest
- #ruby_cmd — Autotest
- #run — Autotest
- #run_tests — Autotest
- #scan_files — ZenTest
- #test_files_for — Autotest
- #test_to_normal — ZenTestMapping
- #unit_diff — UnitDiff
- #unmunge — ZenTestMapping
- #wait_for_changes — Autotest
- #zentest — Module

[Validate]

Generated with the Darkfish Rdoc Generator 2.