Module: ApiTester::BenchmarkModule

Defined in:
lib/api-tester/modules/benchmark_module.rb

Overview

Checks the response times collected during the test run Note: Needs at least one calling module, like GoodCase, to work

Class Method Summary collapse

Class Method Details

.go(contract) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/api-tester/modules/benchmark_module.rb', line 9

def self.go(contract)
  reports = []

  contract.endpoints.each do |endpoint|
    longest_time = endpoint.longest_time
    longest_time[:time] = longest_time[:time] * 1000.0 # Convert from seconds to ms
    if longest_time[:time] > contract.max_time
      print 'F'
      reports << ResponseTimeReport.new(url: endpoint.url,
                                        verb: longest_time[:verb],
                                        payload: longest_time[:payload],
                                        max_time: contract.max_time,
                                        actual_time: longest_time[:time],
                                        description: 'BenchmarkModule')
    else
      print '.'
    end
  end

  reports
end

.orderObject



31
32
33
# File 'lib/api-tester/modules/benchmark_module.rb', line 31

def self.order
  99
end