API test scripts 작성을 중단하세요. 대신 평범한 영어를 사용하세요.
Source: Dev.to
Overview
Octrafic은 API 테스트를 자연어(plain English)로 작성할 수 있게 해줍니다. 테스트하고 싶은 내용을 설명하면, AI가 OpenAPI/Swagger 스펙을 기반으로 적절한 HTTP 요청을 생성하고 실행한 뒤 성공/실패 결과를 보고합니다.
Installation
Linux/macOS
curl -fsSL https://octrafic.com/install.sh | bash
Homebrew
brew install octrafic/tap/octrafic
Windows (PowerShell)
iex (iwr -useb https://octrafic.com/install.ps1)
Setup
Octrafic은 Claude, OpenAI, OpenRouter, Gemini, Ollama, 그리고 llama.cpp를 지원합니다. 직접 API 키를 제공하면 되며, 개발자의 서버를 거치지 않습니다.
Octrafic을 처음 실행하고 인터랙티브 설정 마법사를 따라 진행하세요.
Local LLM (no external API key)
ollama pull qwen2.5:7b
설정 과정에서 Octrafic을 로컬 모델에 연결합니다.
Using the TUI
octrafic -u https://api.example.com -s openapi.json -n "My API"
-u– API 기본 URL-s– OpenAPI/Swagger 스펙 파일 경로-n– 프로젝트 이름
TUI에 들어가면 자연어로 테스트를 기술합니다. 예시:
test the login endpoint with valid credentialstest the login endpoint with a wrong passwordtest creating a new user and check the response structurerun edge cases on the /users endpoint
AI가 올바른 HTTP 메서드, URL, 헤더, 페이로드를 판단해 요청을 실행하고, 응답과 함께 성공/실패 결과를 보여줍니다.
Authentication
세션을 시작할 때 CLI 플래그로 인증 정보를 전달합니다.
Bearer token
octrafic -u https://api.example.com -s spec.json \
--auth bearer --token "your-token-here"
API key
octrafic -u https://api.example.com -s spec.json \
--auth apikey --key X-API-Key --value "your-key-here"
Basic auth
octrafic -u https://api.example.com -s spec.json \
--auth basic --user admin --pass secret123
또는 환경 변수를 사용해 쉘 히스토리에 인증 정보가 남지 않게 할 수 있습니다:
export OCTRAFIC_AUTH_TYPE=bearer
export OCTRAFIC_AUTH_TOKEN=your-token-here
octrafic -u https://api.example.com -s spec.json
Note: Your actual tokens and passwords never leave your machine; the AI only receives the auth type and header names.
Exporting Tests
인터랙티브 세션이 끝난 뒤 AI에게 생성된 테스트를 내보내도록 요청할 수 있습니다:
export these tests to postmanexport tests as a shell scriptexport to pytest and name it test_users_api.py
내보낸 파일은 ~/Documents/octrafic/tests/에 저장됩니다.
테스트를 바로 실행하지 않고 나중에 실행하고 싶다면, 실행 전에 테스트 계획을 내보낼 수도 있습니다.
CI / Pipelines
비‑인터랙티브 환경에서는 octrafic test 서브커맨드를 사용합니다:
octrafic test \
--url https://api.example.com \
--path tests/api-tests.json \
--auth bearer \
--token $API_TOKEN
또는 프롬프트만으로 테스트를 생성하고 바로 실행할 수 있습니다:
octrafic test \
--url https://api.example.com \
--spec openapi.json \
--prompt "test all user endpoints"
모든 테스트가 통과하면 명령은 0을 반환하고, 하나라도 실패하면 1을 반환합니다.
GitHub Actions Example
- name: Run API tests
run: |
octrafic test \
--url ${{ secrets.API_URL }} \
--path tests/api-tests.json \
--auth bearer \
--token ${{ secrets.API_TOKEN }}
Persistence
새 세션은 기본적으로 일시적입니다. TUI 안에서 /save 명령을 사용해 프로젝트를 영구 저장하거나, 상태 표시줄에 나타나는 일시적 표시를 확인하세요.
Contributing & Resources
Octrafic은 오픈소스이며 아직 초기 개발 단계에 있습니다. 문제를 발견하거나 아이디어가 있으면 이슈를 열어 주세요.
- GitHub: https://github.com/Octrafic/octrafic-cli
- Documentation: https://docs.octrafic.com