lib/xcov/model/report.rb in xcov-0.3 vs lib/xcov/model/report.rb in xcov-0.4

- old
+ new

@@ -14,10 +14,12 @@ @coverage_color = self.create_coverage_color @summary = self.create_summary end def average_coverage targets + return 0 if targets.count == 0 + coverage = 0 targets.each do |target| coverage = coverage + target.coverage end coverage / targets.count @@ -40,12 +42,16 @@ end # Class methods def self.map dictionary - targets = dictionary["targets"] - .select { |target| !target["name"].include?(".xctest") } - .map { |target| Target.map(target)} + targets = dictionary["targets"].select { |target| !target["name"].include?(".xctest") } + + # Don't filter test targets if the flag is set + targets = dictionary["targets"] if Xcov.config[:include_test_targets] + + # Create target objects + targets = targets.map { |target| Target.map(target)} Report.new(targets) end end