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

Name Type Required Description
case_id integer true The 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 Code Description
200 OK
400

Invalid or unknown test case

500

An error ocurred

add_bdd

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

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

Parameters

Name Type Required Description
case_id integer true The ID of the case

Example request:

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

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 Code Description
200 OK
400 Invalid or unknown section
403 Insufficient permissions (cannot access project)
500 An error occurred
Was this article helpful?
1 out of 2 found this helpful