MossPilot Test Framework
全功能自动化测试框架,支持API、UI和性能测试,基于pytest构建,面向企业级使用。
核心特性
- 🚀 全场景覆盖: API测试(httpx) + UI测试(playwright) + 性能测试(locust)
- 🏗️ 企业级架构: 模块化设计,支持大规模测试执行
- 📊 丰富报告: 自定义HTML报告 + Allure集成
- 🔧 配置驱动: 多环境配置,无需修改代码
- 📈 实时监控: 企业监控系统集成
- 🔄 CI/CD集成: Jenkins原生支持
安装
pip install mosspilot
快速开始
创建新项目
# 显示版本信息
mosspilot --version
# 创建API测试项目
mosspilot init --project-api my-api-project
# 创建UI测试项目
mosspilot init --project-ui my-ui-project
# 创建性能测试项目
mosspilot init --project-performance my-perf-project
# 创建全功能项目
mosspilot init my-project --template basic
运行测试
# API测试
mosspilot run api
# UI测试
mosspilot run ui
# 性能测试
mosspilot run performance
# 全部测试
mosspilot run all
# 指定环境运行
mosspilot run api --env prod
测试示例
API测试
import pytest
from mosspilot.core.base import TestBase
from mosspilot.modules.api import APIClient, APIAssertions
class TestUserAPI(TestBase):
def setup_method(self, method):
super().setup_method(method)
self.client = APIClient()
self.assertions = APIAssertions()
@pytest.mark.api
def test_get_users(self):
response = self.client.get("/api/users")
self.assertions.assert_status_code(response, 200)
self.assertions.assert_json_contains(response, {"users": []})
UI测试
import pytest
from mosspilot.core.base import TestBase
from mosspilot.modules.ui import UIDriver, UIActions
class TestLoginPage(TestBase):
def setup_method(self, method):
super().setup_method(method)
self.driver = UIDriver()
self.actions = UIActions(self.driver.page)
@pytest.mark.ui
def test_user_login(self):
self.driver.navigate_to("https://example.com/login")
self.actions.fill_input("用户名", "testuser")
self.actions.fill_input("密码", "password123")
self.actions.click_button("登录")
self.actions.wait_for_url("*/dashboard")
性能测试
import pytest
from mosspilot.core.base import TestBase
from mosspilot.modules.performance import PerformanceRunner
class TestAPIPerformance(TestBase):
@pytest.mark.performance
def test_api_load(self):
runner = PerformanceRunner()
tasks = [
{
"name": "获取用户列表",
"method": "GET",
"url": "/api/users",
"weight": 3
}
]
results = runner.run_test(tasks)
assert results["summary"]["failure_rate"] < 0.05
配置管理
支持多环境配置,配置文件使用YAML格式:
# configs/default.yaml
api:
base_url: "https://api.example.com"
timeout: 30
ui:
browser: "chromium"
headless: true
performance:
users: 10
spawn_rate: 2
run_time: "60s"
技术栈
- Python: 3.11+
- 测试框架: pytest
- HTTP客户端: httpx
- 浏览器自动化: playwright
- 性能测试: locust
- 数据库: SQLAlchemy
- 模板引擎: Jinja2
- CLI工具: typer
文档
贡献
欢迎贡献代码!请查看我们的贡献指南。
许可证
本项目采用 Apache License 2.0 许可证。
Metadata
Release files for mosspilot 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mosspilot-0.1.1.tar.gz | 126.9 kB | Without provenance | Details for mosspilot-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mosspilot-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for mosspilot-0.1.1-py3-none-any.whl |
Total release size: 171.9 kB
Release files / mosspilot-0.1.1.tar.gz
| Download URL | mosspilot-0.1.1.tar.gz |
|---|---|
| Size | 126.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66e00e1ef830c7c01d7a6f8050b1c9b39b38ffd61076d28ccfbc4882766b5b8a
|
|
BLAKE2b-256 checksum How to use checksums |
27d8d076f59fec521b75a3eee33ef01c1d0c9204c3e8f8e887abf8f96e693f45
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / mosspilot-0.1.1-py3-none-any.whl
| Download URL | mosspilot-0.1.1-py3-none-any.whl |
|---|---|
| Size | 44.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
558df160b995d4cd29f77de4afa77c8b156470fd67cf43cd9cf78ef7e519e029
|
|
BLAKE2b-256 checksum How to use checksums |
8cacecadd7f67e5501013b436dfd4ee4b86b225c74303b90c39f2a3e22f1ea36
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for mosspilot 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.