Module: Endpoints

Included in:
TestRail::APIClient
Defined in:
lib/endpoints.rb

Instance Method Summary collapse

Instance Method Details

#add_case(section_id, opts = {}) ⇒ Object

Creates a new test case

Examples:

Code Example

@client.add_case(1, {"title":"testCaseName", "type_id":1})

Endpoint Example

index.php?/api/v2/add_case/1&title="foo"&type_id=1

Parameters:

  • section_id (int)

    The id of the test case

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :title (string)

    The title of the test case (required)

  • :template_id (int)

    The ID of the template (field layout) (requires TestRail 5.2 or later)

  • :type_id (int)

    The ID of the case type

  • :priority_id (int)

    The ID of the case priority

  • :estimate (timespan)

    The estimate, e.g. “30s” or “1m 45s”

  • :milestone_id (int)

    The ID of the milestone to link to the test case

  • :refs (string)

    A comma-separated list of references/requirements

See Also:



115
116
117
# File 'lib/endpoints.rb', line 115

def add_case(section_id, opts = {})
  send_post("add_case/#{section_id.to_s}", opts)
end

#add_milestone(project_id, opts = {}) ⇒ Object

Add milestone to project id

Examples:

Endpoint Example

index.php?/api/v2/add_milestone/:project_id

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

See Also:



290
291
292
# File 'lib/endpoints.rb', line 290

def add_milestone(project_id, opts = {})
  send_post("add_milestone/:#{project_id.to_s}", opts)
end

#add_plan(project_id, opts = {}) ⇒ Object

Add plan to project by project id

Examples:

Endpoint Example

index.php?/api/v2/add_plan/:project_id

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

See Also:



355
356
357
# File 'lib/endpoints.rb', line 355

def add_plan(project_id, opts = {})
  send_post("add_plan/:#{project_id.to_s}", opts)
end

#add_plan_entry(plan_id, opts = {}) ⇒ Object

Add plan entries by plan id

Examples:

Endpoint Example

index.php?/api/v2/add_plan_entry/:plan_id

Parameters:

  • plan_id (int)
  • opts (Hash) (defaults to: {})

See Also:



368
369
370
# File 'lib/endpoints.rb', line 368

def add_plan_entry(plan_id, opts = {})
  send_post("add_plan_entry/:#{plan_id.to_s}", opts)
end

#add_project(opts = {}) ⇒ Object

Add a project

Examples:

Endpoint Example

index.php?/api/v2/add_project

Parameters:

  • opts (Hash) (defaults to: {})

See Also:



464
465
466
# File 'lib/endpoints.rb', line 464

def add_project(opts = {})
  send_post("add_project", opts)
end

#add_result(test_id, opts = {}) ⇒ Object

Adds a new test result, comment or assigns a test. It’s recommended to use add_results instead if you plan to add results for multiple tests.

Examples:

Endpoint Example

index.php?/api/v2/add_result/:test_id

Parameters:

  • test_id (int)
  • opts (Hash) (defaults to: {})

See Also:



543
544
545
# File 'lib/endpoints.rb', line 543

def add_result(test_id, opts = {})
  send_post("add_result/:#{test_id.to_s}", opts)
end

#add_result_for_case(run_id, case_id, opts = {}) ⇒ Object

Adds a new test result, comment or assigns a test (for a test run and case combination)

Examples:

Endpoint Example

index.php?/api/v2/add_result_for_case/:run_id/:case_id

Parameters:

  • run_id (int)
  • case_id (int)
  • opts (Hash) (defaults to: {})

See Also:



557
558
559
# File 'lib/endpoints.rb', line 557

def add_result_for_case(run_id, case_id, opts = {})
  send_post("add_result_for_case/:#{run_id.to_s}/:#{case_id.to_s}", opts)
end

#add_results(run_id, opts = {}) ⇒ Object

Adds one or more new test results, comments or assigns one or more tests

Examples:

Endpoint Example

index.php?/api/v2/add_results/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



570
571
572
# File 'lib/endpoints.rb', line 570

def add_results(run_id, opts = {})
  send_post("add_results/:#{run_id.to_s}", opts)
end

#add_results_for_cases(run_id, opts = {}) ⇒ Object

Adds one or more new test results, comments or assigns one or more tests (using the case IDs)

Examples:

Endpoint Example

index.php?/api/v2/add_results_for_cases/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



583
584
585
# File 'lib/endpoints.rb', line 583

def add_results_for_cases(run_id, opts = {})
  send_post("add_results_for_cases/:#{run_id.to_s}", opts)
end

#add_run(project_id, opts = {}) ⇒ Object

Add run by suite id

Examples:

Endpoint Example

index.php?/api/v2/add_run/:project_id

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

See Also:



623
624
625
# File 'lib/endpoints.rb', line 623

def add_run(project_id, opts = {})
  send_post("add_run/:#{project_id.to_s}", opts)
end

#add_section(project_id, opts = {}) ⇒ Object

Add section to suite

Examples:

Endpoint Example

index.php?/api/v2/add_section/:project_id

Code Example

@client.add_section(1, {"suite_id": 5, "name": "This is a new section", "parent_id": 10})

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • suite_id (Int)
  • name (String)
  • parent_id (Int)

See Also:



251
252
253
# File 'lib/endpoints.rb', line 251

def add_section(project_id, opts = {})
  send_post("add_section/#{project_id.to_s}", opts)
end

#add_suite(project_id, opts = {}) ⇒ Object

Add a test suite

Examples:

Endpoint Example

index.php?/api/v2/add_suite/:project_id

Parameters:

  • project_id (int)

    The id of the project containing suites

  • opts (Hash) (defaults to: {})

See Also:



180
181
182
# File 'lib/endpoints.rb', line 180

def add_suite(project_id, opts = {})
  send_post("add_suite/:#{project_id.to_s}", opts)
end

#close_plan(plan_id, opts = {}) ⇒ Object

Close plan by plan id

Examples:

Endpoint Example

index.php?/api/v2/close_plan/:plan_id

Parameters:

  • plan_id (int)
  • opts (Hash) (defaults to: {})

See Also:



408
409
410
# File 'lib/endpoints.rb', line 408

def close_plan(plan_id, opts = {})
  send_post("close_plan/:#{plan_id.to_s}", opts)
end

#close_run(run_id, opts = {}) ⇒ Object

Closes an existing test run and archives its tests & results

Examples:

Endpoint Example

index.php?/api/v2/close_run/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



649
650
651
# File 'lib/endpoints.rb', line 649

def close_run(run_id, opts = {})
  send_post("close_run/#{run_id.to_s}", opts)
end

#delete_case(case_id, opts = {}) ⇒ Object

Delete test case by case id

Examples:

Endpoint Example

index.php?/api/v2/delete_case/:case_id

Parameters:

  • case_id (int)

    The id of the test case

  • opts (Hash) (defaults to: {})

See Also:



141
142
143
# File 'lib/endpoints.rb', line 141

def delete_case(case_id, opts = {})
  send_post("delete_case/:#{case_id.to_s}", opts)
end

#delete_milestone(milestone_id, opts = {}) ⇒ Object

Add milestone to project id

Examples:

Endpoint Example

index.php?/api/v2/delete_milestone/:milestone_id

Parameters:

  • milestone_id (int)
  • opts (Hash) (defaults to: {})

See Also:



316
317
318
# File 'lib/endpoints.rb', line 316

def delete_milestone(milestone_id, opts = {})
  send_post("delete_milestone/:#{milestone_id.to_s}", opts)
end

#delete_plan(plan_id, opts) ⇒ Object

Examples:

Endpoint Example

index.php?/api/v2/delete_plan/:plan_id

See Also:



418
419
420
# File 'lib/endpoints.rb', line 418

def delete_plan(plan_id, opts)
  send_post("delete_plan/:#{plan_id.to_s}", opts)
end

#delete_plan_entry(plan_id, entry_id, opts = {}) ⇒ Object

Examples:

Endpoint Example

index.php?/api/v2/delete_plan_entry/:plan_id/:entry_id


427
428
429
# File 'lib/endpoints.rb', line 427

def delete_plan_entry(plan_id, entry_id, opts = {})
  send_post("delete_plan_entry/:#{plan_id.to_s}/:#{entry_id.to_s}", opts)
end

#delete_project(project_id, opts) ⇒ Object

Delete a project

Examples:

Endpoint Example

index.php?/api/v2/delete_project/:project_id

Parameters:

  • project_id (int)

    The project you want to delete

  • opts (Hash)

See Also:



490
491
492
# File 'lib/endpoints.rb', line 490

def delete_project(project_id, opts)
  send_post("delete_project/:#{project_id.to_s}", opts)
end

#delete_run(run_id, opts = {}) ⇒ Object

Deletes an existing test run.

Examples:

Endpoint Example

index.php?/api/v2/delete_run/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



662
663
664
# File 'lib/endpoints.rb', line 662

def delete_run(run_id, opts = {})
  send_post("delete_run/:#{run_id.to_s}", opts)
end

#delete_suite(suite_id, opts = {}) ⇒ Object

Delete a test suite

Examples:

Endpoint Example

index.php?/api/v2/delete_suite/:suite_id

Parameters:

  • suite_id (int)

    The suite id

  • opts (Hash) (defaults to: {})

See Also:



206
207
208
# File 'lib/endpoints.rb', line 206

def delete_suite(suite_id, opts = {})
  send_post("delete_suite/:#{suite_id.to_s}", opts)
end

#get_case(case_id) ⇒ Object

Returns an existing test case

Examples:

Code Example

@client.get_case(1)

Endpoint Example

GET index.php?/api/v2/get_case/1

Response Example

{
  "created_by": 5,
  "created_on": 1392300984,
  "custom_expected": "..",
  "custom_preconds": "..",
  "custom_steps": "..",
  "custom_steps_separated": [
      {
          "content": "Step 1",
          "expected": "Expected Result 1"
      },
      {
          "content": "Step 2",
          "expected": "Expected Result 2"
     }
  ],
  "estimate": "1m 5s",
  "estimate_forecast": null,
  "id": 1,
  "milestone_id": 7,
  "priority_id": 2,
  "refs": "RF-1, RF-2",
  "section_id": 1,
  "suite_id": 1,
  "title": "Change document attributes (author, title, organization)",
  "type_id": 4,
  "updated_by": 1,
  "updated_on": 1393586511
}

Parameters:

  • case_id (int)

    The id of the test case you want.

See Also:



42
43
44
# File 'lib/endpoints.rb', line 42

def get_case(case_id)
  send_get("get_case/#{case_id.to_s}")
end

#get_cases(project_id, opts = {}) ⇒ Object

Returns a list of test cases for a test suite or specific section in a test suite.

Examples:

Code Example

@client.get_cases(1, {"suite_id":1, "section_id":1})

Endpoint Example

GET index.php?/api/v2/get_cases/1&suite_id=1&section_id=1

Response Example

[
 { "id": 1, "title": "..", .. },
 { "id": 2, "title": "..", .. },
 ..
]

Parameters:

  • project_id (int)

    The id of the project that contains your tests

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • :suite_id (int)

    The ID of the test suite (optional if the project is operating in single suite mode)

  • :section_id (int)

    The ID of the section (optional)

  • :created_after (unix timestamp)

    Only return test cases created after this date (as UNIX timestamp).

  • :created_before (unix timestamp)

    Only return test cases created before this date (as UNIX timestamp).

  • :created_by (int(list))

    A comma-separated list of creators (user IDs) to filter by.

  • :milestone_id (int(list))

    A comma-separated list of milestone IDs to filter by (not available if the milestone field is disabled for the project).

  • :priority_id (int(list))

    A comma-separated list of priority IDs to filter by.

  • :template_id (int(list))

    A comma-separated list of template IDs to filter by (requires TestRail 5.2 or later)

  • :type_id (int(list))

    A comma-separated list of case type IDs to filter by.

  • :updated_after (unix timestamp)

    Only return test cases updated after this date (as UNIX timestamp).

  • :updated_before (unix timestamp)

    Only return test cases updated before this date (as UNIX timestamp).

  • :updated_by (int(list))

    A comma-separated list of users who updated test cases to filter by.

See Also:



75
76
77
# File 'lib/endpoints.rb', line 75

def get_cases(project_id, opts = {})
  send_get("get_cases/#{project_id.to_s}", opts)
end

#get_cases_by_section(project_id, suite_id, section_id, opts = {}) ⇒ Object

Deprecated.

use get_cases instead

Return all test cases in a given project by suite_id and section_id



84
85
86
# File 'lib/endpoints.rb', line 84

def get_cases_by_section(project_id, suite_id, section_id, opts = {})
  send_get("get_cases/#{project_id.to_s}&suite_id=#{suite_id.to_s}&section_id=#{section_id.to_s}", opts)
end

#get_cases_by_suite(project_id, suite_id, opts = {}) ⇒ Object

Deprecated.

use get_cases instead

Return all test cases in a given project by suite_id



93
94
95
# File 'lib/endpoints.rb', line 93

def get_cases_by_suite(project_id, suite_id, opts = {})
  send_get("get_cases/#{project_id.to_s}&suite_id=#{suite_id.to_s}", opts)
end

#get_milestone(milestone_id, opts = {}) ⇒ Object

Get milestone by milestone id

Examples:

Endpoint Example

index.php?/api/v2/get_milestone/:milestone_id

Parameters:

  • milestone_id (int)
  • opts (Hash) (defaults to: {})

See Also:



264
265
266
# File 'lib/endpoints.rb', line 264

def get_milestone(milestone_id, opts = {})
  send_get("get_milestone/:#{milestone_id.to_s}", opts)
end

#get_milestones(project_id, opts = {}) ⇒ Object

Get project milestones by project id

Examples:

Endpoint Example

index.php?/api/v2/get_milestones/:project_id

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

See Also:



277
278
279
# File 'lib/endpoints.rb', line 277

def get_milestones(project_id, opts = {})
  send_get("get_milestones/:#{project_id.to_s}", opts)
end

#get_plan(plan_id, opts = {}) ⇒ Object

Get plan by id

Examples:

Endpoint Example

index.php?/api/v2/get_plan/:plan_id

Parameters:

  • plan_id (int)
  • opts (Hash) (defaults to: {})

See Also:



329
330
331
# File 'lib/endpoints.rb', line 329

def get_plan(plan_id, opts = {})
  send_get("get_plan/:#{plan_id.to_s}", opts)
end

#get_plans(project_id, opts = {}) ⇒ Object

Get plans in project by project id

Examples:

Endpoint Example

index.php?/api/v2/get_plans/:project_id

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

See Also:



342
343
344
# File 'lib/endpoints.rb', line 342

def get_plans(project_id, opts = {})
  send_get("get_plans/:#{project_id.to_s}", opts)
end

#get_project(project_id, opts = {}) ⇒ Object

Get project by project id

Examples:

Endpoint Example

index.php?/api/v2/get_project/:project_id

Parameters:

  • project_id (int)
  • opts (Hash) (defaults to: {})

See Also:



440
441
442
# File 'lib/endpoints.rb', line 440

def get_project(project_id, opts = {})
  send_get("get_project/#{project_id}", opts)
end

#get_projects(opts = {}) ⇒ Object

Get all projects

Examples:

Endpoint Example

index.php?/api/v2/get_projects

Parameters:

  • opts (Hash) (defaults to: {})

See Also:



452
453
454
# File 'lib/endpoints.rb', line 452

def get_projects(opts = {})
  send_get('get_projects', opts)
end

#get_results(test_id, opts = {}) ⇒ Object

Returns a list of test results for a test

Examples:

Endpoint Example

index.php?/api/v2/get_results/:test_id

Parameters:

  • test_id (int)
  • opts (Hash) (defaults to: {})

See Also:



503
504
505
# File 'lib/endpoints.rb', line 503

def get_results(test_id, opts = {})
  send_get("get_results/:#{test_id.to_s}", opts)
end

#get_results_for_case(run_id, case_id, opts = {}) ⇒ Object

Returns a list of test results for a test run and case combination

Examples:

Endpoint Example

index.php?/api/v2/get_results_for_case/:run_id/:case_id

Parameters:

  • run_id (int)
  • case_id (int)
  • opts (Hash) (defaults to: {})

See Also:



517
518
519
# File 'lib/endpoints.rb', line 517

def get_results_for_case(run_id, case_id, opts = {})
  send_get("get_results_for_case/:#{run_id.to_s}/:#{case_id.to_s}", opts)
end

#get_results_for_run(run_id, opts = {}) ⇒ Object

Returns a list of test results for a test run

Examples:

Endpoint Example

index.php?/api/v2/get_results_for_run/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



530
531
532
# File 'lib/endpoints.rb', line 530

def get_results_for_run(run_id, opts = {})
  send_get("get_results_for_run/:#{run_id.to_s}", opts)
end

#get_run(run_id, opts = {}) ⇒ Object

Get run by run id

Examples:

Endpoint Example

index.php?/api/v2/get_run/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



596
597
598
# File 'lib/endpoints.rb', line 596

def get_run(run_id, opts = {})
  send_get("get_run/:#{run_id.to_s}", opts)
end

#get_runs(project_id, opts = {}) ⇒ Object

Get runs by project id

Examples:

Endpoint Example

index.php?/api/v2/get_runs/:project_id

Parameters:

  • project_id (int)
  • plan_id (int)
  • opts (Hash) (defaults to: {})

See Also:



610
611
612
# File 'lib/endpoints.rb', line 610

def get_runs(project_id, opts = {})
  send_get("get_runs/#{project_id.to_s}", opts)
end

#get_section(section_id, opts = {}) ⇒ Object

Return section by id

Examples:

Endpoint Example

index.php?/api/v2/get_section/:section_id

Parameters:

  • section_id (int)
  • opts (Hash) (defaults to: {})

See Also:



220
221
222
# File 'lib/endpoints.rb', line 220

def get_section(section_id, opts = {})
  send_get("get_section/:#{section_id.to_s}", opts)
end

#get_sections(project_id, suite_id, opts = {}) ⇒ Object

Get sections for suite

Examples:

Endpoint Example

index.php?/api/v2/get_sections/:project_id&suite_id=:suite_id

Parameters:

  • suite_id (int)
  • opts (Hash) (defaults to: {})

See Also:



233
234
235
# File 'lib/endpoints.rb', line 233

def get_sections(project_id, suite_id, opts = {})
  send_get("get_sections/#{project_id.to_s}&suite_id=#{suite_id.to_s}", opts)
end

#get_suite(suite_id, opts = {}) ⇒ Object

Return suite by suite id

Examples:

Endpoint Example

index.php?/api/v2/get_suite/:suite_id

Parameters:

  • suite_id (int)

    The suite id

  • opts (Hash) (defaults to: {})

See Also:



154
155
156
# File 'lib/endpoints.rb', line 154

def get_suite(suite_id, opts = {})
  send_get("get_suite/:#{suite_id.to_s}", opts)
end

#get_suites(project_id, opts = {}) ⇒ Object

Return all suites in project by project id

Examples:

Endpoint Example

index.php?/api/v2/get_suites/:project_id

Parameters:

  • opts (Hash) (defaults to: {})
  • project_id (int)

    The id of the project that contains your tests

See Also:



167
168
169
# File 'lib/endpoints.rb', line 167

def get_suites(project_id, opts = {})
  send_get("get_suites/:#{project_id.to_s}", opts)
end

#get_test(test_id, opts = {}) ⇒ Object

Returns an existing test

Examples:

Endpoint Example

index.php?/api/v2/get_test/:test_id

Parameters:

  • test_id (int)
  • opts (Hash) (defaults to: {})

See Also:



675
676
677
# File 'lib/endpoints.rb', line 675

def get_test(test_id, opts = {})
  send_get("get_test/:#{test_id.to_s}", opts)
end

#get_tests(run_id, opts = {}) ⇒ Object

Returns a list of tests for a test run

Examples:

Endpoint Example

index.php?/api/v2/get_tests/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



688
689
690
# File 'lib/endpoints.rb', line 688

def get_tests(run_id, opts = {})
  send_get("get_tests/:#{run_id.to_s}", opts)
end

#update_case(case_id, opts = {}) ⇒ Object

Update test result by case id

Examples:

Endpoint Example

index.php?/api/v2/update_case/:case_id

Parameters:

  • case_id (int)

    The id of the test case

  • opts (Hash) (defaults to: {})

See Also:



128
129
130
# File 'lib/endpoints.rb', line 128

def update_case(case_id, opts = {})
  send_post("update_case/:#{case_id.to_s}", opts)
end

#update_milestone(milestone_id, opts = {}) ⇒ Object

Add milestone to project id

Examples:

Endpoint Example

index.php?/api/v2/update_milestone/:milestone_id

Parameters:

  • milestone_id (int)
  • opts (Hash) (defaults to: {})

See Also:



303
304
305
# File 'lib/endpoints.rb', line 303

def update_milestone(milestone_id, opts = {})
  send_post("update_milestone/:#{milestone_id.to_s}", opts)
end

#update_plan(plan_id, opts = {}) ⇒ Object

Update plan by plan id

Examples:

Endpoint Example

index.php?/api/v2/update_plan/:plan_id

Parameters:

  • plan_id (int)
  • opts (Hash) (defaults to: {})

See Also:



381
382
383
# File 'lib/endpoints.rb', line 381

def update_plan(plan_id, opts = {})
  send_post("update_plan/:#{plan_id.to_s}", opts)
end

#update_plan_entry(plan_id, entry_id, opts = {}) ⇒ Object

Update plan entry by plan id

Examples:

Endpoint Example

index.php?/api/v2/update_plan_entry/:plan_id/:entry_id

Parameters:

  • plan_id (int)
  • entry_id (int)

    Id of entry

  • opts (Hash) (defaults to: {})

See Also:



395
396
397
# File 'lib/endpoints.rb', line 395

def update_plan_entry(plan_id, entry_id, opts = {})
  send_post("update_plan_entry/:#{plan_id.to_s}/:#{entry_id.to_s}", opts)
end

#update_project(project_id, opts) ⇒ Object

Update a project

Examples:

Endpoint Example

index.php?/api/v2/update_project/:project_id

Parameters:

  • project_id (int)

    The project you want to update

  • opts (Hash)

See Also:



477
478
479
# File 'lib/endpoints.rb', line 477

def update_project(project_id, opts)
  send_post("update_project/:#{project_id.to_s}", opts)
end

#update_run(run_id, opts = {}) ⇒ Object

Updates existing test run

Examples:

Endpoint Example

index.php?/api/v2/update_run/:run_id

Parameters:

  • run_id (int)
  • opts (Hash) (defaults to: {})

See Also:



636
637
638
# File 'lib/endpoints.rb', line 636

def update_run(run_id, opts = {})
  send_post("update_run/:#{run_id.to_s}", opts)
end

#update_suite(suite_id, opts = {}) ⇒ Object

update a test suite

Examples:

Endpoint Example

index.php?/api/v2/update_suite/:suite_id

Parameters:

  • suite_id (int)

    The suite id

  • opts (Hash) (defaults to: {})

See Also:



193
194
195
# File 'lib/endpoints.rb', line 193

def update_suite(suite_id, opts = {})
  send_post("update_suite/:#{suite_id.to_s}", opts)
end