a Unit Testing Framework for Ruby - test-unit

test-unit

test-unit is a xUnit family unit testing framework for Ruby.

Backward compatibility

test-unit 1.2.3 is the same version as bundled in Ruby 1.8.

Install:

% sudo gem install test-unit -v 1.2.3

Usage:

require "rubygems"
gem "test-unit", "1.2.3"
require "test/unit"

test-unit 1.2.3 reference manual

Feature split

test-unit splits some packages by feature. e.g. GTK+ test runner is a different package.

Install:

% sudo gem install test-unit-runner-gtk2

Usage:

require "test/unit/runner/gtk2"

You can use --runner=gtk2 option to use GTK+ test runner.

Here are test-unit related packages.

test-unit Build Status for Ruby 2.1+Build Status for Ruby 1.9 and 2.0

This package provides core feature.

test-unit: The latest release

3.6.2 is the latest release. It had been released at 2024-02-16.

test-unit: Install

Install:

% sudo gem install test-unit

Usage:

require "test-unit"

test-unit: Document

test-unit-rails

This is a Rails adapter for test-unit. This also sets RR, a test double library, and Capybara, a library for integration test, up. You can get many features test environment.

test-unit-rails: The latest release

7.0.0 is the latest release. It had been released at 2021-12-20.

test-unit-rails: Install

You add the following codes to your Gemfile:

group :development, :test do
  gem 'test-unit-rails'
end

And you update bundled gems:

% bundle update

You change test/test_helper.rb like the following codes:

# require 'rails/test_helper'
require 'test/unit/rails/test_help'

test-unit-activesupport

This is an Activesupport adapter for test-unit. You can use test-unit 2 instead of minitest as ActiveSupport::TestCase backend.

test-unit-activesupport: The latest release

1.1.1 is the latest release. It had been released at 2022-03-06.

test-unit-activesupport: Install

Require test/unit/active_support:

require "test/unit/active_support"
require "active_support"

Now you can use full test-unit features with ActiveSupport::TestCase.

require "test/unit/active_support"
require "active_support"
class YourTest < ActiveSupport::TestCase
  # ...
end

test-unit-full

This is a meta package to use all useful extension packages.

test-unit-full: The latest release

0.0.5 is the latest release. It had been released at 2016-10-16.

test-unit-full: Install

Install:

% sudo gem install test-unit-full

Usage:

require "test/unit/full"

test-unit-notify

notification on GNOME notification on Mac OS X
This package provides a test notifier.
X Window System based environment such ad GNOME, Xfce, KDE and so on
"notify-send" command is used for notifying test result.
Mac OS X
"growlnotify" command or terminal-notifier is used for notifying test result.
Windows
"growlnotify.exe" command is used for notifying test result. You need to install Growl for Windows.

test-unit-notify: The latest release

1.0.4 is the latest release. It had been released at 2014-10-13.

test-unit-notify: Install

Install:

% sudo gem install test-unit-notify

Usage:

require "test/unit/notify"

You can use --notify option to notify test result by popup at the end.

test-unit-notify: Document

test-unit-rr

This package provides a RR, a test double library, adapter for test-unit.

test-unit-rr: The latest release

1.0.5 is the latest release. It had been released at 2016-01-18.

test-unit-rr: Install

Install:

% sudo gem install test-unit-rr

Usage:

require "test/unit/rr"

test-unit-rr: Document

test-unit-capybara

This package provides a Capybara, an integration testing helper library for Rack applications, adapter for test-unit.

test-unit-capybara: The latest release

1.1.1 is the latest release. It had been released at 2021-03-15.

test-unit-capybara: Install

Install:

% sudo gem install test-unit-capybara

Usage:

require 'test/unit/capybara'

class MyRackApplication
  def call(env)
    html = <<-HTML
<html>
  <head>
    <title>Welcome! - my site</title>
  </head>
  <body>
    <h1>Welcome!</h1>
    <div class="header">
      <p>No navigation.</p>
    </div>
  </body>
</html>
HTML
   [200, {"Content-Type" => "text/html"}, [html]]
  end
end

class TestMyRackApplication < Test::Unit::TestCase
  include Capybara::DSL

  def setup
    Capybara.app = MyRackApplication.new
  end

  def test_title
    visit("/")
    within("h1") do
      assert_equal("Welcome!", text)
    end
  end

  def test_no_sidebar
    visit("/")
    within("body") do
      assert_not_find(".sidebar")
    end
  end

  def test_header_content
    visit("/")
    within(".header") do
      find("ol.navi")
      # This fails with the following message:
      #
      # <"ol.navi">(:css) expected to find a element in
      # <<div class="header">
      #       <p>No navigation.</p>
      #     </div>>
      #
      # This messages shows the current context. You don't need to
      # entire HTML. You just see the current context moved by "within".
      # It helps you debug a problem without save_and_open_page.
    end
  end
end

test-unit-capybara: Document

test-unit-runner-tap

This package provides a test runner that provides TAP and TAP-Y/J test output formats.

test-unit-runner-tap: The latest release

1.0.0 is the latest release. It had been released at 2012-02-06.

test-unit-runner-tap: Install

Install:

% sudo gem install test-unit-runner-tap

Usage:

require "test/unit/runner/tap"

You can use --runner=tap, --runner=tapy and --runner=tapj to output test results in TAP and TAP-Y/J format.

test-unit-runner-gtk2

This package provides a GTK+ based test runner.

test-unit-runner-gtk2: The latest release

0.0.2 is the latest release. It had been released at 2011-02-09.

test-unit-runner-gtk2: Install

Install:

% sudo gem install test-unit-runner-gtk2

Usage:

require "test/unit/runner/gtk2"

You can use --runner=gtk2 to run tests with GTK+ based test runner.

test-unit-runner-tk

This package provides a Tk based test runner.

test-unit-runner-tk: The latest release

0.0.1 is the latest release. It had been released at 2008-06-17.

test-unit-runner-tk: Install

Install:

% sudo gem install test-unit-runner-tk

Usage:

require "test/unit/runner/tk"

You can use --runner=tk to run tests with Tk based test runner.

test-unit-runner-fox

This package provides a FOX Toolkit based test runner.

test-unit-runner-fox: The latest release

0.0.1 is the latest release. It had been released at 2008-06-17.

test-unit-runner-fox: Install

Install:

% sudo gem install test-unit-runner-fox

Usage:

require "test/unit/runner/fox"

You can use --runner=fox to run tests with Fox toolkit based test runner.

For developers

test-unit welcome to your contributions.

Repositories

test-unit uses git repository on GitHub. Here is a list to get each source code.

test-unit
% git clone https://github.com/test-unit/test-unit.git
test-unit-rails
% git clone https://github.com/test-unit/test-unit-rails.git
test-unit-activesupport
% git clone https://github.com/test-unit/test-unit-activesupport.git
test-unit-full
% git clone https://github.com/test-unit/test-unit-full.git
test-unit-notify
% git clone https://github.com/test-unit/test-unit-notify.git
test-unit-rr
% git clone https://github.com/test-unit/test-unit-rr.git
test-unit-capybara
% git clone https://github.com/test-unit/test-unit-capybara.git
test-unit-runner-gtk2
% git clone https://github.com/test-unit/test-unit-runner-gtk2.git
test-unit-runner-tk
% git clone https://github.com/test-unit/test-unit-runner-tk.git
test-unit-runner-fox
% git clone https://github.com/test-unit/test-unit-runner-fox.git

Commit mail

You can receive commit mails from Commit Email as a Service(test-unit@ml.commit-email.info)