Class: TestRail::TestCase

Inherits:
Object
  • Object
show all
Defined in:
lib/testrail/test_case.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_client) ⇒ TestCase

Returns a new instance of TestCase.



6
7
8
9
# File 'lib/testrail/test_case.rb', line 6

def initialize(api_client)
  @api_client = api_client
  @release = TestRail::Release.new(@api_client)
end

Instance Method Details

#build_test_case_hash(release, test_name) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/testrail/test_case.rb', line 28

def build_test_case_hash(release,test_name)
  test_case = Hash.new
  test_case["title"] = test_name
  test_case["milestone_id"] = release["id"]

  test_case
end

#create(test_name, section, project) ⇒ Object



17
18
19
20
21
22
# File 'lib/testrail/test_case.rb', line 17

def create(test_name, section, project)
  release = @release.find_or_create(project)
  test_case_data = build_test_case_hash(release,test_name)
  test_path = "add_case/#{section["id"]}"
  @api_client.send_post(test_path, test_case_data)
end

#find(test_name, suite, section, project) ⇒ Object



11
12
13
14
15
# File 'lib/testrail/test_case.rb', line 11

def find(test_name, suite, section, project)
  test_path = "get_cases/#{project["id"]}&suite_id=#{suite["id"]}&section_id=#{section["id"]}"
  tests = @api_client.send_get(test_path)
  tests.select{ |x| x["title"]== test_name }.first
end

#find_or_create(test_name, suite, section, project) ⇒ Object



24
25
26
# File 'lib/testrail/test_case.rb', line 24

def find_or_create(test_name, suite, section, project)
  find(test_name, suite, section, project) || create(test_name, section, project)
end