Skip to content

Commit

Permalink
Use the duration of Cucumber::Core::Test::Result in the JSON formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
brasmusson committed Sep 20, 2014
1 parent ac69440 commit c6535ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/cucumber/formatter/gherkin_formatter_adapter.rb
Expand Up @@ -84,7 +84,6 @@ def before_step(step)
end
@gf.match(match)
end
@step_time = Time.now
end

def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
Expand Down Expand Up @@ -139,9 +138,10 @@ def before_examples(examples)

#used for capturing duration
def after_step(step)
step_finish = (Time.now - @step_time)
unless @outline and @options[:expand] and not @in_instantiated_scenario
@gf.append_duration(step_finish)
unless step.duration == :unknown
@gf.append_duration(step.duration / 10 ** 9.0)
end
end
end

Expand Down
8 changes: 6 additions & 2 deletions lib/cucumber/reports/legacy_formatter.rb
Expand Up @@ -917,6 +917,7 @@ def max
class LegacyResultBuilder
attr_reader :status
def initialize(result)
@duration = :unknown
@result = result
@result.describe_to(self)
end
Expand Down Expand Up @@ -951,10 +952,12 @@ def append_to_exception_backtrace(line)
return self
end

def duration(*); end
def duration(duration, *)
@duration = duration
end

def step_invocation(step_match, step, indent, background, configuration, messages, embeddings)
Legacy::Ast::StepInvocation.new(step_match, @status, step_exception(step, configuration), indent, background, step, messages, embeddings)
Legacy::Ast::StepInvocation.new(step_match, @status, @duration, step_exception(step, configuration), indent, background, step, messages, embeddings)
end

def scenario(name, location)
Expand Down Expand Up @@ -1111,6 +1114,7 @@ def describe_exception_to(formatter)

StepInvocation = Struct.new(:step_match,
:status,
:duration,
:exception,
:indent,
:background,
Expand Down

0 comments on commit c6535ce

Please sign in to comment.