Add namespaced test module logging
This commit is contained in:
parent
966dec5b03
commit
75d74d2e3c
|
@ -35,17 +35,20 @@ module Msf
|
|||
end
|
||||
|
||||
def it(msg = "", &block)
|
||||
@current_it_msg = msg
|
||||
@tests += 1
|
||||
begin
|
||||
result = block.call
|
||||
unless result
|
||||
print_error("FAILED: #{msg}")
|
||||
print_error("FAILED: #{error}") if error
|
||||
@failures += 1
|
||||
print_error("FAILED: #{error}") if error
|
||||
@current_it_msg = nil
|
||||
print_error("FAILED: #{msg}")
|
||||
return
|
||||
end
|
||||
rescue SkipTestError => e
|
||||
@skipped += 1
|
||||
@current_it_msg = nil
|
||||
print_status("SKIPPED: #{msg} (#{e.message})")
|
||||
rescue ::Exception => e
|
||||
@failures += 1
|
||||
|
@ -54,6 +57,8 @@ module Msf
|
|||
dlog("Exception in testing - #{msg}")
|
||||
dlog("Call stack: #{e.backtrace.join("\n")}")
|
||||
return
|
||||
ensure
|
||||
@current_it_msg = nil
|
||||
end
|
||||
|
||||
print_good("#{msg}")
|
||||
|
@ -67,6 +72,22 @@ module Msf
|
|||
def passed
|
||||
@tests - @failures
|
||||
end
|
||||
|
||||
# When printing to console, additionally prepend the current test name
|
||||
[
|
||||
:print,
|
||||
:print_line,
|
||||
:print_status,
|
||||
:print_good,
|
||||
|
||||
:print_warning,
|
||||
:print_error,
|
||||
:print_bad,
|
||||
].each do |method|
|
||||
define_method(method) do |msg|
|
||||
super(@current_it_msg ? "[#{@current_it_msg}] #{msg}" : msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module ModuleTest::PostTest
|
||||
|
|
Loading…
Reference in New Issue