Class: DevCreek::MetricCollector

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/devcreek_metriccollector.rb

Direct Known Subclasses

RSpecAdapter, TestUnitAdapter

Constant Summary

Constants included from Log

Log::DEV_CREEK_LOG

Instance Method Summary collapse

Methods included from Log

#logger

Instance Method Details

#endObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/devcreek_metriccollector.rb', line 45

def end
  @dev_creek_test_suite.has_finished
  if @dev_creek_test_suite.has_test_results?
    payload = @dev_creek_test_suite.to_xml(UUID.timestamp_create().to_s)
    logger.debug "Submitting body: \n #{payload}"
    
    if DevCreek::Core.instance().enabled != false 
      logger.info "Attempting DevCreek transmission..."
      response = DevCreek::Transmitter.submit(payload)     
      case response
      when Net::HTTPSuccess
        logger.info "...transmission successful."
      else
        logger.error "...failure transmiting #{@dev_creek_test_suite.framework} results to DevCreek - HTTPResponse with Code # #{response.code}, HTTPResponse message \"#{response.message}\""
      end  
    end
  end  
end

#start(framework) ⇒ Object



19
20
21
22
23
# File 'lib/devcreek_metriccollector.rb', line 19

def start(framework)
  logger.debug "Started collecting metrics from #{framework} framework"
  @framework = framework
  @dev_creek_test_suite = DevCreek::TestSuite.new(framework)
end

#test_failed(test_id, due_to_a_failure) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/devcreek_metriccollector.rb', line 35

def test_failed(test_id, due_to_a_failure)
  logger.debug "#{@framework} test_failed: #{test_id}"
  
  if due_to_a_failure
    @dev_creek_test_suite.test_results[test_id].has_a_failure
  else
    @dev_creek_test_suite.test_results[test_id].has_an_error
  end
end

#test_finished(test_id) ⇒ Object



30
31
32
33
# File 'lib/devcreek_metriccollector.rb', line 30

def test_finished(test_id)
  logger.debug "#{@framework} test_finished: #{test_id}"
  @dev_creek_test_suite.test_results[test_id].has_finished
end

#test_started(test_id, test_name, test_class) ⇒ Object



25
26
27
28
# File 'lib/devcreek_metriccollector.rb', line 25

def test_started(test_id, test_name, test_class)
  logger.debug "#{@framework} test_started: #{test_id}"
  @dev_creek_test_suite.test_results[test_id] = DevCreek::TestResult.new(test_name, test_class) 
end