るりまサーチ

最速Rubyリファレンスマニュアル検索!
3件ヒット [1-3件を表示] (0.139秒)
トップページ > クエリ:i[x] > クエリ:-[x] > クエリ:assert_equal[x]

別のキーワード

  1. _builtin -
  2. open-uri open
  3. irb/input-method new
  4. irb/input-method gets
  5. matrix -

ライブラリ

モジュール

キーワード

検索結果

MiniTest::Assertions#assert_equal(expected, actual, message = nil) -> true (21301.0)

与えられた期待値と実際の値が等しい場合、検査にパスしたことになります。

...セージを指定します。
文字列か Proc を指定します。Proc である場合は Proc#call した
結果を使用します。

@raise MiniTest::Assertion 与えられた期待値と実際の値が等しくない場合に発生します。

@see Object#==...

test/unit (6132.0)

ユニットテストを行うためのライブラリです。

...してください。

* Test::Unit - Ruby用単体テストフレームワーク: https://test-unit.github.io/

なお、2.2.0より前のtest/unit は当時バンドルしていた minitest/unit を使って再実装し
ていましたが、上記のtest/unitと完全な互換性がある訳で...
...グフレームワークの歴史(2014年版) https://www.clear-code.com/blog/2014/11/6.html
* RubyKaigi 2015:The history of testing framework in Ruby https://www.clear-code.com/blog/2015/12/12.html

=== 使い方

Test::Unit は以下のように使います。

まずテスト対象のソ...
...す。

require 'test/unit'
require 'foo'

class TC_Foo < Test::Unit::TestCase
def setup
@obj = Foo.new
end

# def teardown
# end

def test_foo
assert_equal
("foo", @obj.foo)
end
def test_bar
assert_equal
("bar", @obj.bar)...

minitest/unit (6030.0)

ユニットテストを行うためのライブラリです。

...ユニットテストを行うためのライブラリです。

=== 使い方

minitest/unit は以下のように使います。

テスト対象のソース (foo.rb) を用意します。

class Foo
def foo
"foo"
end
def bar
"foo"
end
end

次にユニットテス...
...ん。

require 'minitest/unit'
require 'foo'

MiniTest::Unit.autorun

class TestFoo < MiniTest::Unit::TestCase
def setup
@foo = Foo.new
end
# teardown はあまり使わない
def teardown
@foo = nil
end

def test_foo
assert_equal
"foo", @foo....
....
Finished in 0.000940 seconds.

1) Failure:
test_bar(TestFoo) [test_foo.rb:20]:
Expected "bar", not "foo".

2 tests, 2 assertions, 1 failures, 0 errors, 0 skips

test_bar だけテストしたい場合は以下のようなオプションを与えます。

$ ruby test_foo.rb -n te...