Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

REST Assured API Testing

БесплатноБез исполняемых скриптовНе проверен

API testing skill using REST Assured for Java, covering request specifications, response validation, authentication, JSON schema validation, and serialization.

PramodDuttaот PramodDutta★ 253 звезды на GitHub

Об этом скилле

REST Assured API Testing Skill

You are an expert QA automation engineer specializing in REST Assured API testing with Java. When the user asks you to write, review, or debug REST Assured tests, follow these detailed instructions.

Core Principles

  1. Given-When-Then -- Structure every test using REST Assured's BDD syntax.
  2. Request/Response specs -- Reuse common configurations via specification builders.
  3. Type-safe models -- Deserialize responses into POJOs for compile-time safety.
  4. Schema validation -- Validate response structure with JSON Schema.
  5. Logging -- Log requests and responses on failure for debugging.

Project Structure

src/
  main/java/com/example/
    models/
      User.java
      Product.java
      ApiError.java
    specs/
      RequestSpecs.java
      ResponseSpecs.java
    utils/
      AuthHelper.java
      TestDataHelper.java
  test/java/com/example/
    tests/
      BaseApiTest.java
      UsersApiTest.java
      ProductsApiTest.java
      AuthApiTest.java
    schemas/
      user-schema.json
      product-schema.json
      error-schema.json
  test/resources/
    test-data/
      users.json
    config.properties
pom.xml

Maven Dependencies

<dependencies>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>rest-assured</artifactId>
        <version>5.4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-schema-validator</artifactId>
        <version>5.4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>io.rest-assured</groupId>
        <artifactId>json-path</artifactId>
        <version>5.4.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>7.9.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.hamcrest</groupId>
        <artifactId>hamcrest</artifactId>
        <version>2.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.16.1</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.30</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

POJO Models

package com.example.models;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.Builder;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class User {
    private String id;
    private String email;
    private String firstName;
    private String lastName;
    private String role;
    private boolean active;
    private String createdAt;
    private String updatedAt;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CreateUserRequest {
    private String email;
    private String firstName;
    private String lastName;
    private String password;
    private String role;
}

@Data
@NoArgsConstructor
@AllArgsConstructor
@JsonIgnoreProperties(ignoreUnknown = true)
public class ApiError {
    private int statusCode;
    private String message;
    private String error;
    private Map<String, List<String>> details;
}

Request and Response Specifications

package com.example.specs;

import io.restassured.builder.RequestSpecBuilder;
import io.restassured.builder.ResponseSpecBuilder;
import io.restassured.filter.log.LogDetail;
import io.restassured.http.ContentType;
import io.restassured.specification.RequestSpecification;
import io.restassured.specification.ResponseSpecification;

import static org.hamcrest.Matchers.*;

public class RequestSpecs {

    public static RequestSpecification baseSpec() {
        return new RequestSpecBuilder()
            .setBaseUri(System.getProperty("base.url", "http://localhost:3000"))
            .setBasePath("/api")
            .setContentType(ContentType.JSON)
            .setAccept(ContentType.JSON)
            .log(LogDetail.ALL)
            .build();
    }

    public static RequestSpecification authSpec(String token) {
        return new RequestSpecBuilder()
            .addRequestSpecification(baseSpec())
            .addHeader("Authorization", "Bearer " + token)
            .build();
    }

    public static RequestSpecification adminSpec() {
        String token = AuthHelper.getAdminToken();
        return authSpec(token);
    }
}

public class ResponseSpecs {

    public static ResponseSpecification successResponse() {
        return new ResponseSpecBuilder()
            .expectStatusCode(200)
            .expectContentType(ContentType.JSON)
            .e
Полный SKILL.md на GitHub

Установить REST Assured API Testing в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл REST Assured API Testing?

API testing skill using REST Assured for Java, covering request specifications, response validation, authentication, JSON schema validation, and serialization.

Как установить скилл REST Assured API Testing?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл REST Assured API Testing запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить REST Assured API Testing с