class TestML::Runtime::Unit
Attributes
planned[RW]
testcase[RW]
Public Instance Methods
assert_EQ(got, want)
click to toggle source
# File lib/testml/runtime/unit.rb, line 60 def assert_EQ(got, want) got = got.value want = want.value # TODO Move this logic to testml/diff if got != want if want.match /\n/ File.open('/tmp/got', 'w') {|f| f.write got} File.open('/tmp/want', 'w') {|f| f.write want} STDERR.write(`diff -u /tmp/want /tmp/got`) end end testcase.assert_equal want, got, get_label end
assert_HAS(got, has)
click to toggle source
# File lib/testml/runtime/unit.rb, line 74 def assert_HAS(got, has) got = got.value has = has.value assertion = got.index(has) if !assertion msg = <<"..." Failed TestML HAS (~~) assertion. This text: '#{got}' does not contain this string: '#{has}' ... STDERR.write(msg) end testcase.assert(assertion, get_label) end
assert_OK(got)
click to toggle source
# File lib/testml/runtime/unit.rb, line 90 def assert_OK(got) testcase.assert(got.bool.value, get_label) end
check_plan()
click to toggle source
# File lib/testml/runtime/unit.rb, line 29 def check_plan if ! @planned title plan_begin @planned = true end end
plan_begin()
click to toggle source
# File lib/testml/runtime/unit.rb, line 51 def plan_begin;end
plan_end()
click to toggle source
# File lib/testml/runtime/unit.rb, line 53 def plan_end if plan = @function.getvar('Plan') count = @function.getvar('TestNumber').value testcase.assert_equal plan.value.to_i, count, 'Tests Planned' end end
run(unittest_testcase)
click to toggle source
Calls superclass method
TestML::Runtime#run
# File lib/testml/runtime/unit.rb, line 16 def run(unittest_testcase) @testcase = unittest_testcase @planned = false super() check_plan plan_end end
run_assertion(*args)
click to toggle source
Calls superclass method
TestML::Runtime#run_assertion
# File lib/testml/runtime/unit.rb, line 24 def run_assertion(*args) check_plan super(*args) end
skip_test(reason)
click to toggle source
# File lib/testml/runtime/unit.rb, line 47 def skip_test(reason) fail "TODO" end
title()
click to toggle source
XXX Need to disable by default and provide a simple way to turn on.
# File lib/testml/runtime/unit.rb, line 38 def title if title = @function.getvar('Title') title = title.value title = "\n=== #{title} ===\n" # TODO Figure out when to print titles. # STDERR.write title end end