Module: Endpoints

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

Instance Method Summary collapse

Instance Method Details

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

Note:

For more information about custom fields, see guroc docs

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:

  • The ID of the section the test case should be added to

  • (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

  • :custom_fields (varies)

    Custom fields are supported as well and must be submitted with their system name, prefixed with ‘custom_’

See Also:



100
101
102
# File 'lib/endpoints.rb', line 100

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:

  • (defaults to: {})

See Also:



279
280
281
# File 'lib/endpoints.rb', line 279

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:

  • (defaults to: {})

See Also:



344
345
346
# File 'lib/endpoints.rb', line 344

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:

  • (defaults to: {})

See Also:



357
358
359
# File 'lib/endpoints.rb', line 357

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:

  • (defaults to: {})

See Also:



468
469
470
# File 'lib/endpoints.rb', line 468

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:

  • (defaults to: {})

See Also:



550
551
552
# File 'lib/endpoints.rb', line 550

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:

  • (defaults to: {})

See Also:



564
565
566
# File 'lib/endpoints.rb', line 564

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:

  • (defaults to: {})

See Also:



577
578
579
# File 'lib/endpoints.rb', line 577

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:

  • (defaults to: {})

See Also:



590
591
592
# File 'lib/endpoints.rb', line 590

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:

  • (defaults to: {})

See Also:



631
632
633
# File 'lib/endpoints.rb', line 631

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:

  • (defaults to: {})

Options Hash (opts):

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

See Also:



240
241
242
# File 'lib/endpoints.rb', line 240

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:

  • The id of the project containing suites

  • (defaults to: {})

See Also:



165
166
167
# File 'lib/endpoints.rb', line 165

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:

  • (defaults to: {})

See Also:



397
398
399
# File 'lib/endpoints.rb', line 397

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:

  • (defaults to: {})

See Also:



657
658
659
# File 'lib/endpoints.rb', line 657

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:

  • The id of the test case

  • (defaults to: {})

See Also:



126
127
128
# File 'lib/endpoints.rb', line 126

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:

  • (defaults to: {})

See Also:



305
306
307
# File 'lib/endpoints.rb', line 305

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:



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

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


416
417
418
# File 'lib/endpoints.rb', line 416

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:

  • The project you want to delete

See Also:



494
495
496
# File 'lib/endpoints.rb', line 494

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:

  • (defaults to: {})

See Also:



670
671
672
# File 'lib/endpoints.rb', line 670

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:

  • The suite id

  • (defaults to: {})

See Also:



191
192
193
# File 'lib/endpoints.rb', line 191

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,s
  "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:

  • 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}")
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:

  • The id of the project that contains your tests

  • (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
78
# File 'lib/endpoints.rb', line 75

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

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

Get milestone by milestone id

Examples:

Endpoint Example

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

Parameters:

  • (defaults to: {})

See Also:



253
254
255
# File 'lib/endpoints.rb', line 253

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:

  • (defaults to: {})

See Also:



266
267
268
# File 'lib/endpoints.rb', line 266

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

#get_plan(plan_id) ⇒ Object

Get plan by id

Examples:

Endpoint Example

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

Parameters:

See Also:



318
319
320
# File 'lib/endpoints.rb', line 318

def get_plan(plan_id)
  send_get("get_plan/#{plan_id.to_s}")
end

#get_plans(project_id) ⇒ Object

Get plans in project by project id

Examples:

Endpoint Example

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

Parameters:

See Also:



331
332
333
# File 'lib/endpoints.rb', line 331

def get_plans(project_id)
  send_get("get_plans/#{project_id.to_s}")
end

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

Get project by project id

Examples:

Endpoint Example

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

Parameters:

  • (defaults to: {})

See Also:



429
430
431
432
# File 'lib/endpoints.rb', line 429

def get_project(project_id, opts = {})
  options = param_stringify(opts)
  send_get("get_project/#{project_id.to_s}&#{options}")
end

#get_projects(opts = {}) ⇒ Object

Get all projects

Examples:

Endpoint Example

index.php?/api/v2/get_projects

Code Example [get all projects]

client.get_projects

Code Example [get active projects]

client.get_projects({'is_completed':0})

Code Example [get completed projects]

client.get_projects({'is_completed':1})

Response Example

[
 { "id": 1, "name": "Project1", ... },
 { "id": 2, "name": "Project2", ... },
 ..
]

Parameters:

  • (defaults to: {})

Options Hash (opts):

  • :is_completed (bool)

    1 == completed projects, 2 == active projects

See Also:



455
456
457
458
# File 'lib/endpoints.rb', line 455

def get_projects(opts = {})
  options = param_stringify(opts)
  send_get("get_projects&#{options}")
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:

  • (defaults to: {})

See Also:



507
508
509
510
# File 'lib/endpoints.rb', line 507

def get_results(test_id, opts = {})
  options = param_stringify(opts)
  send_get("get_results/#{test_id.to_s}&#{options}")
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:

  • (defaults to: {})

See Also:



522
523
524
525
# File 'lib/endpoints.rb', line 522

def get_results_for_case(run_id, case_id, opts = {})
  options = param_stringify(opts)
  send_get("get_results_for_case/#{run_id.to_s}/#{case_id.to_s}&#{options}")
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:

  • (defaults to: {})

See Also:



536
537
538
539
# File 'lib/endpoints.rb', line 536

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

#get_run(run_id) ⇒ Object

Get run by run id

Examples:

Endpoint Example

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

Parameters:

See Also:



603
604
605
# File 'lib/endpoints.rb', line 603

def get_run(run_id)
  send_get("get_run/#{run_id.to_s}")
end

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

Get runs by project id

Examples:

Endpoint Example

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

Parameters:

  • (defaults to: {})

See Also:



617
618
619
620
# File 'lib/endpoints.rb', line 617

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

#get_section(section_id) ⇒ Object

Return section by id

Examples:

Endpoint Example

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

Parameters:

See Also:



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

def get_section(section_id)
  send_get("get_section/#{section_id.to_s}")
end

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

Get sections for suite

Examples:

Endpoint Example

index.php?/api/v2/get_sections/1&suite_id=2

Code Example

client.get_sections(1, {"suite_id":2})

Parameters:

  • (defaults to: {})

See Also:



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

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

#get_suite(suite_id) ⇒ Object

Return suite by suite id

Examples:

Endpoint Example

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

Parameters:

  • The suite id

See Also:



139
140
141
# File 'lib/endpoints.rb', line 139

def get_suite(suite_id)
  send_get("get_suite/#{suite_id.to_s}")
end

#get_suites(project_id) ⇒ Object

Return all suites in project by project id

Examples:

Endpoint Example

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

Parameters:

  • The id of the project that contains your tests

See Also:



152
153
154
# File 'lib/endpoints.rb', line 152

def get_suites(project_id)
  send_get("get_suites/#{project_id.to_s}")
end

#get_test(test_id) ⇒ Object

Returns an existing test

Examples:

Endpoint Example

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

Parameters:

See Also:



682
683
684
# File 'lib/endpoints.rb', line 682

def get_test(test_id)
  send_get("get_test/#{test_id.to_s}")
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:

  • (defaults to: {})

See Also:



695
696
697
698
# File 'lib/endpoints.rb', line 695

def get_tests(run_id, opts = {})
  options = param_stringify(opts)
  send_get("get_tests/#{run_id.to_s}&#{options}")
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:

  • The id of the test case

  • (defaults to: {})

See Also:



113
114
115
# File 'lib/endpoints.rb', line 113

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:

  • (defaults to: {})

See Also:



292
293
294
# File 'lib/endpoints.rb', line 292

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:

  • (defaults to: {})

See Also:



370
371
372
# File 'lib/endpoints.rb', line 370

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:

  • Id of entry

  • (defaults to: {})

See Also:



384
385
386
# File 'lib/endpoints.rb', line 384

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:

  • The project you want to update

See Also:



481
482
483
# File 'lib/endpoints.rb', line 481

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:

  • (defaults to: {})

See Also:



644
645
646
# File 'lib/endpoints.rb', line 644

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:

  • The suite id

  • (defaults to: {})

See Also:



178
179
180
# File 'lib/endpoints.rb', line 178

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