Class: Ace::Test::EndToEndRunner::Models::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/test/end_to_end_runner/models/test_case.rb

Overview

Data model representing a single test case definition.

Contains parsed frontmatter metadata and the full markdown body from an independent test case file within a scenario directory.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tc_id:, title:, content:, file_path:, pending: nil, goal_format: nil, declared_artifacts: [], optional_artifacts: []) ⇒ TestCase

Returns a new instance of TestCase.

Parameters:

  • tc_id (String)

    Test case identifier (e.g., “TC-001”)

  • title (String)

    Test case title from frontmatter

  • content (String)

    Full markdown body (below frontmatter)

  • file_path (String)

    Absolute path to the source test file

  • pending (String, nil) (defaults to: nil)

    Pending reason (presence = pending, value = reason)

  • goal_format (String, nil) (defaults to: nil)

    Test case source format (“standalone”)

  • declared_artifacts (Array<String>) (defaults to: [])

    Required artifact paths under results/tc/*

  • optional_artifacts (Array<String>) (defaults to: [])

    Optional artifact paths under results/tc/*



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 23

def initialize(tc_id:, title:, content:, file_path:, pending: nil, goal_format: nil,
  declared_artifacts: [], optional_artifacts: [])
  @tc_id = tc_id
  @title = title
  @content = content
  @file_path = file_path
  @pending = pending
  @goal_format = goal_format
  @declared_artifacts = declared_artifacts
  @optional_artifacts = optional_artifacts
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def content
  @content
end

#declared_artifactsObject (readonly)

Returns the value of attribute declared_artifacts.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def declared_artifacts
  @declared_artifacts
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def file_path
  @file_path
end

#goal_formatObject (readonly)

Returns the value of attribute goal_format.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def goal_format
  @goal_format
end

#optional_artifactsObject (readonly)

Returns the value of attribute optional_artifacts.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def optional_artifacts
  @optional_artifacts
end

#pendingObject (readonly)

Returns the value of attribute pending.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def pending
  @pending
end

#tc_idObject (readonly)

Returns the value of attribute tc_id.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def tc_id
  @tc_id
end

#titleObject (readonly)

Returns the value of attribute title.



12
13
14
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 12

def title
  @title
end

Instance Method Details

#pending?Boolean

Whether this test case is pending (should be skipped)

Returns:

  • (Boolean)


37
38
39
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 37

def pending?
  !pending.nil?
end

#short_idString

Generate short test case ID for directory naming

Returns:

  • (String)

    Short ID (e.g., “tc001” from “TC-001”, “tc001a” from “TC-001a”)



43
44
45
46
47
48
# File 'lib/ace/test/end_to_end_runner/models/test_case.rb', line 43

def short_id
  match = tc_id.match(/TC-(\d+[a-z]*)/i)
  return "tc#{match[1]}" if match

  tc_id.downcase.gsub(/[^a-z0-9]/, "")
end