CoveredSourceCoveredSus

module Sus

Integrates coverage tracking with Sus.

Definitions

def initialize(...)

Initialize Sus with optional coverage tracking. Loads and starts coverage only when the COVERAGE environment variable is set.

Implementation

def initialize(...)
	super
	
	# Defer loading the coverage configuration unless we are actually running with coverage started to avoid performance cost/overhead:
	if ENV["COVERAGE"]
		require_relative "config"
		
		@covered = Covered::Config.load(root: self.root)
		if @covered.record?
			@covered.start
		end
	else
		@covered = nil
	end
end

def after_tests(assertions)

Finish coverage tracking after tests complete.

Signature

parameter assertions Object

The assertions object passed through to Sus.

Implementation

def after_tests(assertions)
	super(assertions)
	
	if @covered&.record?
		@covered.finish
		@covered.call(self.output.io)
	end
end

def covered

The active coverage configuration.

Signature

returns Covered::Config | Nil

The active coverage configuration when coverage is enabled.

Implementation

def covered
	@covered
end