$ bundle exec ruby some_test.rb Run options: # Running tests: ... Finished tests in 1.017405s, 2.9487 tests/s, 1.9658 assertions/s. 普通はこれでも十分なんですが、セグメンテーションフォールトとかの低レベルなバグを追っているときだとちょっとつらい。 そういうときは-vオプションを使ってやればいい。 $ bundle exec ruby some_test.rb -v Run options: -v # Running tests: SomeTest#test_a = 0.00 s = . SomeTest#test_b = 1.01 s = . SomeTest#test_c = 0.01 s = . Finished tests in 1.017389s, 2
Test::Unitを使っているんだけどassertのタイプ何があったっけなと毎回調べてるのでまとめておく 参照 : http://ruby-doc.org/stdlib-2.1.0/libdoc/test/unit/rdoc/Test/Unit/Assertions.html 大体こんだけ assert assert_block assert_equal assert_no_match assert_not_equal assert_not_nil assert_not_same assert_not_send assert_nothing_raised assert_nothing_thrown assert_raise assert_raise_with_message assert_respond_to assert_send assert_throw assert(test, [
2014年12月にRuby 2.2がリリースされる予定です1。 Ruby 2.2にはRuby 1.9.1のときに外されたtest-unitというテスティングフレームワークが再びバンドルされる予定です。Rubyのテスティングフレームワーク周りに詳しくない人にはよくわからない状況でしょう。そこで、Rubyのテスティングフレームワークの歴史を説明することで状況を整理します。 名称の整理 この説明の中ではたくさんのテスティングフレームワークが登場します。似たようなものもあるため、最初にテスティングフレームワークの名称を整理します。この説明の中で登場する名称は次の通りです。 RubyUnit Lapidary rubyunit Test::Unit test/unit test-unit miniunit minitest RSpec 違いがわかりますか?ざっくり説明すると次の通りです。 RubyU
The RSpec Bookをやってみるで、RSpec + Cucumberが良さそうなことはわかったのだけど、具体的にどう適用したらよいのかわからない。特にほとんどのアプリで最初に作るべきログイン機能の部分。 そこで、Rails Tutorial for Devise with RSpec and Cucumberをやってみる。 環境 RVM ruby 1.9.3p194 Rails 3.2.8 新しいプロジェクト作成 % rails new rails3-devise-rspec-cucumber -T「-T」は、Unit::Testを入れないためのオプション。理由はRSpecを入れるため。 Gemfileに以下のライブラリを追加。 rspec-rails cucumber-rails database_cleaner factory_girl_rails (参考:func09:has
← Exceptions | RubyDoc → Unit testing is a great way to catch errors early in the development process, if you dedicate time to writing appropriate and useful tests. As in other languages, Ruby provides a framework in its standard library for setting up, organizing, and running tests called Test::Unit. There are other very popular testing frameworks, rspec and cucumber come to mind. Specifically, T
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. In
test-unitはRuby用のxUnit系の単体テストフレームワークです。Ruby 1.8まではRuby本体に標準添付されていましたが、Ruby 1.9.1からはminitestというフレームワークが標準添付されています。test-unitがRuby 1.8に標準添付されていた頃はほとんど機能拡張などがされず、RSpecなどより新しいテスティングフレームワークから見劣りするものになっていました。しかし、Ruby標準添付ではなく、1つのプロジェクトとして開発が進められるようになってからは活発に開発が進められています。Ruby本体のバージョンアップに関係なく新しいバージョンをリリースできるようになったことも開発が活発になった理由の1つです。Ruby標準添付の頃のtest-unitしか知らない人は、一度、最新のtest-unitを使ってみてはいかがでしょうか。とても使いやすくなっていることを実
Included in: TestCase Defined in: lib/test/unit/assertions.rb, lib/test/unit/assertions.rb, lib/test/unit/assertions.rb Test::Unit::Assertions contains the standard Test::Unit assertions. Assertions is included in Test::Unit::TestCase. To include it in your own code and use its functionality, you simply need to rescue Test::Unit::AssertionFailedError. Additionally you may override add_assertion to
test-unitはRuby用のxUnit系の単体テストフレームワークです。2.3.1からデータ駆動テスト機能が追加されていたのですが、2.5.3まではリファレンスに記述がなく、知る人ぞ知る機能でした。 2013-01-23にリリースされた2.5.4ではデータ駆動テスト機能についてのドキュメントが追加されています。 データ駆動テスト自体の説明はUxUを用いたデータ駆動テストの記述を参照してください。 Cucumberのscenario outlinesに似ていると言えばピンと来る人もいるのではないでしょうか。 Cucumberのscenario outlinesも前述のククログ記事の通り、テストのデータとロジックを分離しているのでデータ駆動テストの一種と言えます。 今回は、データ駆動テストを導入した例を見ながらtest-unitでのデータ駆動テスト機能の使い方を紹介します。なお、以降の説明
テストの書き方 基本 今までのTest::Unitと変わらないので,classで書く.ただ,昔のTest::Unitとは違い,TestCase毎に呼ばれるstartupやshutdownなどが増えている. require 'test/unit' class TestSample < Test::Unit::TestCase class << self # テスト群の実行前に呼ばれる.変な初期化トリックがいらなくなる def startup p :_startup end # テスト群の実行後に呼ばれる def shutdown p :_shutdown end end # 毎回テスト実行前に呼ばれる def setup p :setup end # テストがpassedになっている場合に,テスト実行後に呼ばれる.テスト後の状態確認とかに使える def cleanup p :cleanup
Rails4からはActiveSupport::TestCaseがTest::UnitからMiniTest::Unit::TestCaseのサブクラスに変わっている。 MiniTestはSpecなDSLをサポートしているので、RSpecを入れずともBDDスタイルでテストが書けるようになる。 ということで、いろいろtest_helper.rbをゴニョってたらminitest-rails-specというズバリなGemを見つけたので(><)これを使う。 minitest-spec-railsでやってくれることは、ざっくりいうと、RailsのActiveSupport::TestCaseにMinitest::Spec::DSLをextendして、ControllerとかHelperクラスをテスト対象クラスに追加して、beforeとかafterとかのDSLを使えるようにしてくれるだけというシンプルな
ICANN, the Internet Corporation for Assigned Names and Numbers, requires us to ask you as a Registrant of a domain name to verify your contact information for this domain with your provider. As a Registrant of a domain name, a new domain registration or changes to the first name, last name, contact address or email address of an existing domain name, requires verification of the information within
I’ve been using Ruby for over 3 years and have written tests for about as long. That’s something great about the Ruby community, it encourages you to do proper testing. Through this time I’ve worked with many different testing frameworks. I’ve come to appreciate the simplicity of Test::Unit. RSpec adds a level of complication with its DSL that I do not see the appeal of. Tests should be the most t
追記 2014-12-10 === この記事ですが、Ruby on Rails 3.2.x 系を前提にした内容となっており、 新しい Rails 4.0.x、4.1.x 系では少しやり方が異なります。 取り急ぎで申し訳ございませんが、とりあえず下記に、最新の Minitest の記事を紹介いたします。 A Guide to Testing Rails Applications — Ruby on Rails Guides (※英文) 追記ここまで === Ruby や Ruby on Rails で使用されるテストフレームワークは、何がポピュラーか? The Ruby Toolbox - Unit Test Frameworks RSpec が第1党で、次に Minitest という Test::Unit から置き換えられたフレームワークが人気だ。個人的には RSpec を使う機会が多かっ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く