Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
32 lines (31 sloc) 3.06 KB
---
test_unit: "Ruby - Test::Unit\n\
===============================================================================\n\
Basic Usage:\n\n require 'test/unit'\n\n class Test_SomethingToTest < Test::Unit::TestCase\n def setup\n #will be run prior to each test\n end\n\n # Replace this with your real tests.\n def test_truth\n assert true\n end\n end\n\n\n\
Assertions:\n\
===============================================================================\n\
All assertions also take an optional argument of failure message.\n\n\
> assert(boolean,[msg])\t \n Ensures that the object/expression is true.\n\n\
> assert_block([msg]) { block }\n Most basic assertion\n\n\
> assert_equal(obj1, obj2, [msg])\n Ensures that obj1 == obj2 is true.\n\n\
> assert_in_delta(expecting, actual, delta, [msg])\n Ensures that the numbers expecting and actual are within delta of each other.\n \n\
> assert_instance_of(class, obj, [msg])\n Ensures that obj is of the class type.\n\n\
> assert_kind_of(class, obj, [msg])\n Ensures that obj is or descends from class.\n\n\
> assert_match(regexp, string, [msg])\n Ensures that a string matches the regular expression.\n\n\
> assert_nil(obj, [msg])\n Ensures that obj.nil? is true.\n\n\
> assert_no_match(regexp, string, [msg])\n Ensures that a string doesn\xE2\x80\x99t matches the regular expression.\n \n\
> assert_not_equal(obj1, obj2, [msg])\t \n Ensures that obj1 == obj2 is false.\n\n\
> assert_not_nil(obj, [msg])\n Ensures that obj.nil? is false.\n\n\
> assert_not_same((obj1, obj2, [msg])\n Ensures that obj1.equal?(obj2) is false.\n\n\
> assert_nothing_raised(exception1, ...) { block }\n Ensures that the given block doesn\xE2\x80\x99t raise one of the given exceptions.\n \n\
> assert_nothing_thrown([msg]) { block }\n Passes if block does not throw anything \n\n\
> assert_operator(obj1, operator, obj2, [msg])\n Ensures that obj1.operator(obj2) is true.\n\n\
> assert_raise(except1, except2, ...) { block }\n Ensures that the given block raises one of the given exceptions.\n\n\
> assert_respond_to(obj, symbol, [msg])\n Ensures that obj has a method called symbol.\n\n\
> assert_same(obj1, obj2, [msg])\n Ensures that obj1.equal?(obj2) is true.\n \n\
> assert_send(array, [msg])\n Ensures that executing the method listed in array[1] on the object in\n array[0] with the parameters of array[2 and up] is true. This one is weird eh?\n\n\
> assert_throws(symbol, [msg]) { block }\n Ensures that the given block throws the symbol.\n \n\
> flunk([msg])\n Ensures failure. This is useful to explicitly mark a test that isn\xE2\x80\x99t \n finished yet.\n\n\
===============================================================================\n\
Updated by: Adam G.\n\
Updated at: 2010-04-22"