برای export یا import کردن سناریوهای BDD مربوط به test caseها، از متدهای API زیر استفاده کنید.
get_bdd #
یک سناریوی BDD را از یک test case بهصورت فایل .feature export میکند.
GET index.php?/api/v2/get_bdd/{case_id}
پارامترها #
| نام | نوع | الزامی | توضیحات |
|---|---|---|---|
| case_id | عدد صحیح | بله | ID مربوط به test case |
نمونه درخواست:
# Export the BDD scenario with a case ID of 2133
GET index.php?/api/v2/get_bdd/2133
محتوای پاسخ #
@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
کدهای پاسخ #
| کد وضعیت | توضیحات |
|---|---|
| 200 | OK |
| 400 |
test case نامعتبر یا ناشناخته است |
| 500 |
خطایی رخ داد |
add_bdd #
یک سناریوی BDD را بهصورت فایل .feature در یک test case import/upload میکند.
POST index.php?/api/v2/add_bdd/{section_id}
پارامترها #
| نام | نوع | الزامی | توضیحات |
|---|---|---|---|
| section_id | عدد صحیح | بله | ID مربوط به بخش |
نمونه درخواست:
# Import the BDD scenario with a section ID of 188
POST index.php?/api/v2/add_bdd/188
محتوای پاسخ #
{
"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
}
کدهای پاسخ #
| کد وضعیت | توضیحات |
|---|---|
| 200 | OK |
| 400 | section نامعتبر یا ناشناخته است |
| 403 | مجوز کافی ندارید (نمیتوانید به project دسترسی داشته باشید) |
| 500 | خطایی رخ داد |

