Sha256: 6371bdc2e9887d28c28afaadf956d8b7f331ca75789b63cc2f6b0df522e1953f

Contents?: true

Size: 1.05 KB

Versions: 2

Compression:

Stored size: 1.05 KB

Contents

require 'ostruct'

module JunitModel
  # A TestGroup is the top level object in a Junit tree.
  class TestGroup < OpenStruct
    def test_count
      tests.to_i
    end

    def failures_count
      failures.to_i
    end

    def passed?
      failures_count == 0
    end

    def to_xml
      XMLBuilder.xml_for_result(self)
    end

    alias failure_count failures_count
    alias passed passed?
  end
end

module JunitModel
  # A TestSuite belongs to a TestGroup and has an array of TestCase
  class TestSuite < OpenStruct
    def test_count
      tests.to_i
    end

    def failures_count
      failures.to_i
    end

    def passed?
      failures == '0'
    end

    def test_cases
      testcase
    end

    def failed_test_cases
      test_cases.reject(&:passed?)
    end

    def passed_test_cases
      test_cases.select(&:passed?)
    end

    alias failure_count failures_count
    alias passed passed?
  end
end

module JunitModel
  # A TestCase is the atomic unit of a Junit file
  class TestCase < OpenStruct
    def passed?
      failure.nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
junit_model-0.1.1 lib/junit_model/models.rb
junit_model-0.1.0 lib/junit_model/models.rb