Created
October 27, 2011 07:41
-
-
Save rgarner/1318991 to your computer and use it in GitHub Desktop.
Test::Unit example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test/unit" | |
class ObjectiveFailure | |
def valid? | |
false | |
end | |
def children | |
['ted'] | |
end | |
def name | |
nil | |
end | |
end | |
class MyTest < Test::Unit::TestCase | |
def setup | |
@object = ObjectiveFailure.new | |
end | |
# Fake test | |
test "test_new_object_is_valid" do | |
assert @object.valid? | |
end | |
def test_new_object_has_three_children | |
assert_equal 3, @object.children.length | |
end | |
def test_name_should_equal_barry | |
assert_equal "barry", @object.name | |
end | |
def test_amelia_in_children | |
assert @object.children.include?('amelia') | |
assert @object.children.include('ted') | |
end | |
end | |
# Started | |
# F | |
# | |
# Failure: | |
# test: test_new_object_is_valid(MyTest) [/Users/russ/RubymineProjects/testy/test/unit/my_test.rb:24]: | |
# <false> is not true. | |
# | |
# F | |
# | |
# Failure: | |
# test_amelia_in_children(MyTest) [/Users/russ/RubymineProjects/testy/test/unit/my_test.rb:36]: | |
# <false> is not true. | |
# | |
# F | |
# | |
# Failure: | |
# test_name_should_equal_barry(MyTest) [/Users/russ/RubymineProjects/testy/test/unit/my_test.rb:32]: | |
# <"barry"> expected but was | |
# <nil> | |
# | |
# diff: | |
# ? "barry" | |
# ? nil | |
# | |
# F | |
# | |
# Failure: | |
# test_new_object_has_three_children(MyTest) [/Users/russ/RubymineProjects/testy/test/unit/my_test.rb:28]: | |
# <3> expected but was | |
# <0> | |
# | |
# diff: | |
# ? 3 | |
# ? 0 | |
# | |
# | |
# Finished in 0.020596 seconds. | |
# | |
# 4 tests, 4 assertions, 4 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications | |
# 0% passed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment