mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-07 06:22:43 +08:00
4.2 KiB
4.2 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
HttpRunner v5 is a comprehensive testing framework written in Go that supports API testing, load testing, and UI automation across multiple platforms (Android/iOS/Harmony/Browser). The framework integrates LLM technology for intelligent test automation and uses a pure visual-driven approach (OCR/CV/VLM) for UI testing.
Development Commands
Building
make build- Build the hrp CLI tool with static linking and embedded version infogo build -o output/hrp ./cmd/cli- Alternative build commandmake test- Run unit tests with race detection
Testing
go test -race -v ./...- Run all tests with race detectiongo test -v ./tests/...- Run test suite onlygo test -v ./uixt/...- Run UI automation testsgo test -v ./cmd/...- Run CLI command tests
Code Quality
go mod tidy- Clean up dependenciesgofmt -w .- Format code- Pre-commit hooks are available in
scripts/directory
Core Architecture
Main Components
Core Testing Engine
runner.go- Main test runner (HRPRunner, CaseRunner, SessionRunner)testcase.go- Test case definitions and loading (ITestCase interface)step.go- Step definitions and configurationsstep_*.go- Specific step implementations (request, api, testcase, ui, etc.)
Step Types
step_request.go- HTTP/HTTPS requestsstep_api.go- API calls with parametersstep_testcase.go- Nested test casesstep_websocket.go- WebSocket communicationstep_ui.go- UI automation stepsstep_transaction.go- Transaction groupingstep_rendezvous.go- Synchronization pointsstep_shell.go- Shell command executionstep_function.go- Custom function calls
UI Automation (uixt/)
device.go- Device abstraction interface (IDevice)driver.go- Driver interface and session managementandroid_*.go- Android platform implementation (ADB/UIAutomator2)ios_*.go- iOS platform implementation (WDA)harmony_*.go- HarmonyOS implementation (HDC)browser_*.go- Web browser automationai/- AI-powered UI interaction (OCR/VLM)
CLI Interface (cmd/)
root.go- Root command and global configurationrun.go- Test executionserver.go- HTTP server modeconvert.go- Format conversion utilitiesbuild.go- Plugin buildingadb/- Android device managementios/- iOS device management
Plugin System
The framework supports both Go and Python plugins:
build.go- Plugin compilation systemplugin.go- Plugin interface definitions- Templates in
internal/scaffold/templates/plugin/
Configuration Management
config.go- Global configurationinternal/config/- Environment and settings management- Environment variables and .env file support
Key Design Patterns
Interface-Driven Architecture
ITestCaseinterface for different test case sourcesIDeviceinterface for multi-platform supportIDriverinterface for different automation drivers
Step-Based Testing
- Each test consists of configurable steps
- Steps support setup/teardown hooks
- Variables and parameters flow between steps
Plugin Architecture
- Hashicorp go-plugin for Go plugins
- Python plugin support via funplugin
- Template-based plugin generation
Testing Approach
Test Formats Supported
- YAML/JSON test cases
- Go test files
- Python pytest integration
- HAR, Postman, cURL conversion
UI Testing Strategy
- Pure visual-driven (no element locators)
- OCR/VLM for text recognition
- Cross-platform unified API
- AI-powered interaction planning
Development Guidelines
Code Structure
- Core framework logic in root directory
- Platform-specific implementations in
uixt/ - CLI commands in
cmd/ - Internal utilities in
internal/ - Examples in
examples/
Code Standards
- All code comments must be written in English
- All documentation must be written in Chinese
Dependencies
- Go 1.23+ required
- Uses Cobra for CLI
- Integrates with multiple automation frameworks
- LLM integration via CloudWeGo Eino
Build Configuration
- Static linking for deployment
- Version info embedded via ldflags
- Cross-platform builds supported