Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Panel
titleAPI Spec Document

Method

POST


URL

/api/auth/login


1. Headers

Header

STT

Value

Required

Content-Type

application/json

Yes

2. Parameters

Field

Source Data Type / Length 

Description

Sample Values






2. Body

STT

Path

Field

Data Type / Length

Required

Description

email

string

Yes

User's registered email address

password

string

Yes

User's password

Note

Sample Values















3. Response

Mã lỗi

Mô tả

200

OK

Thành công

400

Bad Request

Nhập đủ thông tin

401

Unauthorized

Sai Username hoặc Pass

/ Incoming Data Specification

STT

Field

Data Type / Length

Description

Note

Sample Values




















3.4 Mô tả các trường dữ liệu trên màn hình:

Field

(Trường dữ liệu)

Type

(Kiểu dữ liệu)

Required

(Bắt buộc)

Validation

(Quy định)

Description

(Mô tả)

Username

Text

Yes

Maxlength = 50


Password

Text

Yes

Maxlength = 50



...


Viết Acceptance Criteria (AC) theo dạng Given - When - Then (Nhằm hướng tới việc kiểm thử tự động) 

Cấu trúc Given - When - Then được viết theo Gherkin, là cú pháp mô tả hành vi hệ thống (Behavior Driven Development) dưới dạng các tình huống sử dụng (scenarios). cách viết tiêu chí nghiệm thu (AC) bằng ngôn ngữ giả tự nhiên (dễ đọc cho cả kỹ thuật và không kỹ thuật), sau đó liên kết với mã kiểm thử tự động để thực thi.

Ví dụ: 

User Story: Đăng nhập

AC: 

ScenarioGiven When Then 
Đăng nhập thành côngNgười dùng đang ở trang đăng nhập

Nhập thông tin hợp lệ

And nhấn nút đăng nhập

Chuyển đến trang dashboard
Code Block
languagejava
// LoginSteps.java
package steps;

import io.cucumber.java.en.*;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class LoginSteps {
    WebDriver driver;

    @Given("người dùng đang ở trang đăng nhập")
    public void openLoginPage() {
        driver = new ChromeDriver();
        driver.get("https://example.com/login");
    }

    @When("nhập tên đăng nhập và mật khẩu hợp lệ")
    public void enterValidCredentials() {
        driver.findElement(By.id("username")).sendKeys("validUser");
        driver.findElement(By.id("password")).sendKeys("validPass123");
    }

    @When("nhấn nút đăng nhập")
    public void clickLoginButton() {
        driver.findElement(By.id("loginButton")).click();
    }

    @Then("người dùng được chuyển đến trang dashboard")
    public void verifyDashboard() {
        String currentUrl = driver.getCurrentUrl();
        assert currentUrl.contains("/dashboard");
        driver.quit();
    }
}