BDDs

Use the following API methods to export or import BDD scenarios from test cases.

get_bdd

Exports a BDD scenario from a test case as a .feature file.

GET index.php?/api/v2/get_bdd/{case_id}

Parameters

NameTypeRequiredDescription
case_idintegertrueThe ID of the case

Example request:

# Export the BDD scenario with a case ID of 2133
GET index.php?/api/v2/get_bdd/2133

Response content

@APP-1
Feature: Users cannot login with invalid credentials
The login page should not allow users to login with invalid credentials, and it should not reveal sensitive info relating to the correctness of credentials.Background:Given I am viewing the login page

Scenario Outline: User cannot login with invalid username
Given I have entered into the username field
And I have entered into the password field
When I click the login button
Then I see I am not logged in
Examples:
|username|password|
|invalid1|validP@55w0rd!|
|invalid2@com|validP@55w0rd!|

Scenario: User cannot login with invalid password
Given I have entered "myname@valid.com" into the username field
And I have entered "invalid" into the password field
When I click the login button
Then I see I am not logged in

Rule: Login responses should not reveal sensitive information
Examples: Login response should not flag invalid username
Given I have entered an invalid username into the username field
And I have entered a valid password into the password field
When I click the login button
Then I see an error message
And the error message does not state that the username was incorrect
Examples: Login response should not flag invalid password
Given I have entered an invalid password into the password field
And I have entered a valid username into the username field
When I click the login button
Then I see an error message
And the error message does not state that the password was incorrect

Response codes

Status CodeDescription
200OK
400Invalid or unknown test case
500An error ocurred

get_bdds_count

Returns the number of BDD test cases for a project.

GET index.php?/api/v2/get_bdds_count/{project_id}

Parameters

Accepts the same filter parameters as get_bdds.

NameTypeRequiredDescription
project_idintegertrueThe ID of the project

Example request:

# Get the BDD case count for project ID 1
GET index.php?/api/v2/get_bdds_count/1

Response content

{
 "count": 42,
 "pages": 1,
 "requests": 1
}

The pages and requests fields indicate how many paginated calls the full result set would require at the default page size.

Response codes

Status CodeDescription
200OK
400Invalid or unknown project
403Insufficient permissions (cannot access project)
500An error occurred

add_bdd

Imports/uploads a BDD scenario from a test case as a .feature file.

POST index.php?/api/v2/add_bdd/{section_id}

Parameters

NameTypeRequiredDescription
section_idintegertrueThe ID of the section

Example request:

# Import the BDD scenario with a section ID of 188
POST index.php?/api/v2/add_bdd/188

Response content

{
 "id": 2136,
 "title": "Users cannot login with invalid credentials",
 "section_id": 188,
 "template_id": 4,
 "type_id": 7,
 "priority_id": 2,
 "milestone_id": null,
 "refs": "APP-1",
 "created_by": 1,
 "created_on": 1653052591,
 "updated_by": 1,
 "updated_on": 1653052591,
 "estimate": null,
 "estimate_forecast": null,
 "suite_id": 12,
 "display_order": 3,
 "is_deleted": 0,
 "custom_automation_type": 0,
 "custom_preconds": "The login page should not allow users to login with invalid credentials, and it should not reveal sensitive info relating to the correctness of credentials.Background:Given I am viewing the login page\n\t",
 "custom_steps": null,
 "custom_testrail_bdd_scenario": "[{\"content\":\"\\tScenario Outline: User cannot login with invalid username\\n\\tGiven I have entered into the username field\\n\\tAnd I have entered into the password field\\n\\tWhen I click the login button\\n\\tThen I see I am not logged in\\n\\n\\tExamples:\\n\\t| username  | password    |\\n\\t| invalid1  | validP@55w0rd! |\\n\\t| invalid2@com | validP@55w0rd! |\"},{\"content\":\"\\tScenario: User cannot login with invalid password\\n\\tGiven I have entered \"myname@valid.com\" into the username field\\n\\tAnd I have entered \"invalid\" into the password field\\n\\tWhen I click the login button\\n\\tThen I see I am not logged in\"},{\"content\":\"\\tExample: Login response should not flag invalid username\\n\\tGiven I have entered an invalid username into the username field\\n\\tAnd I have entered a valid password into the password field\\n\\tWhen I click the login button\\n\\tThen I see an error message\\n\\tAnd the error message does not state that the username was incorrect\"},{\"content\":\"\\tExample: Login response should not flag invalid password\\n\\tGiven I have entered an invalid password into the password field\\n\\tAnd I have entered a valid username into the username field\\n\\tWhen I click the login button\\n\\tThen I see an error message\\n\\tAnd the error message does not state that the password was incorrect\"}]",
 "custom_expected": null,
 "custom_steps_separated": null,
 "custom_mission": null,
 "custom_goals": null
}

Response codes

Status CodeDescription
200OK
400Invalid or unknown section
403Insufficient permissions (cannot access project)
500An error occurred
Was this article helpful?
6 out of 31 found this helpful