Class: GitlabQuality::TestTooling::CodeCoverage::CoverageData

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab_quality/test_tooling/code_coverage/coverage_data.rb

Constant Summary collapse

RESPONSIBLE =
'responsible'
DEPENDENT =
'dependent'

Instance Method Summary collapse

Constructor Details

#initialize(code_coverage_by_source_file, source_file_to_tests, tests_to_feature_categories, feature_categories_to_teams, source_file_types = {}, test_classifications = {}) ⇒ CoverageData

Returns a new instance of CoverageData.

Parameters:

  • code_coverage_by_source_file (Hash<String, Hash>)

    Source file mapped to test coverage data

  • source_file_to_tests (Hash<String, Array<String>>)

    Source files mapped to all test files testing them

  • tests_to_feature_categories (Hash<String, Array<String>>)

    Test files mapped to all feature categories they belong to

  • feature_categories_to_teams (Hash<String, Hash>)

    Mapping of feature categories to teams (i.e., groups, stages, sections)

  • source_file_types (Hash<String, String>) (defaults to: {})

    Mapping of source files to their types (frontend, backend, etc.)

  • test_classifications (Hash<String, String>) (defaults to: {})

    Mapping of test files to their responsibility classification (responsible or dependent)



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/gitlab_quality/test_tooling/code_coverage/coverage_data.rb', line 22

def initialize(
  code_coverage_by_source_file, source_file_to_tests, tests_to_feature_categories,
  feature_categories_to_teams, source_file_types = {}, test_classifications = {}
)
  @code_coverage_by_source_file = code_coverage_by_source_file
  @source_file_to_tests = source_file_to_tests
  @tests_to_feature_categories = tests_to_feature_categories
  @feature_categories_to_teams = feature_categories_to_teams
  @source_file_types = source_file_types
  @test_classifications = test_classifications
end

Instance Method Details

#as_db_tableArray<Hash<Symbol, String>>

Returns Mapping of column name to row value.

Examples:

Return value

[
  {
    file: "app/channels/application_cable/channel.rb"
    line_coverage: 100.0
    branch_coverage: 95.0
    function_coverage: 100.0
    source_file_type: "backend"
    is_responsible: true
    is_dependent: false
    feature_category: "team_planning"
    group: "project_management"
    stage: "plan"
    section: "dev"
  },
  ...
]

Returns:

  • (Array<Hash<Symbol, String>>)

    Mapping of column name to row value



53
54
55
# File 'lib/gitlab_quality/test_tooling/code_coverage/coverage_data.rb', line 53

def as_db_table
  all_files.flat_map { |file| records_for_file(file) }
end