Class: Sapphire::Testing::CoverageReporter

Inherits:
Object
  • Object
show all
Defined in:
lib/sapphire/Testing/CoverageReporter.rb

Instance Method Summary collapse

Constructor Details

#initializeCoverageReporter

Returns a new instance of CoverageReporter.



5
6
7
# File 'lib/sapphire/Testing/CoverageReporter.rb', line 5

def initialize()
  @output = $stdout
end

Instance Method Details

#OutputResultsObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/sapphire/Testing/CoverageReporter.rb', line 9

def OutputResults()
  @output.puts ""

  $features.each do |feature|
    @output.puts "Feature: " + feature.token.to_s

    feature.requirements.each do |requirement|
      @output.puts "\tRequirement: " + requirement.token.to_s


      positiveCount = 0
      negativeCount = 0
      boundaryCount = 0
      exceptionCount = 0

      expectedPositiveCount = 0
      expectedNegativeCount = 0
      expectedBoundaryCount = 0
      expectedExceptionCount = 0

      requirement.behaviors.each do |behavior|

        if behavior.type == :positive
          positiveCount += 1 if behavior.is_covered
          expectedPositiveCount += 1
        end

        if behavior.type == :negative
          negativeCount += 1 if behavior.is_covered
          expectedNegativeCount += 1
        end

        if behavior.type == :boundary
          boundaryCount += 1 if behavior.is_covered
          expectedBoundaryCount += 1
        end

        if behavior.type == :exception
          exceptionCount += 1 if behavior.is_covered
          expectedExceptionCount += 1
        end
      end

      @output.puts "\t\tPositive: " + positiveCount.to_s + "/" + expectedPositiveCount.to_s + " covered."
      @output.puts "\t\tNegative: " + negativeCount.to_s + "/" + expectedNegativeCount.to_s + " covered."
      @output.puts "\t\tBoundary: " + boundaryCount.to_s + "/" + expectedBoundaryCount.to_s + " covered."
      @output.puts "\t\tException: " + exceptionCount.to_s + "/" + expectedExceptionCount.to_s + " covered."
    end
  end
end