测试时间: 2026-07-21 15:10 CST 测试环境: Windows 11 / Go 后端 + SQLite / Wails v2 工作目录:
D:\lq\Smart Parking\lc_garage测试套件:e2e_test.go(11个) +e2e_edge_cases_test.go(16个) 总计: 27 个用例,19 PASS / 8 FAIL
| 分类 | 通过 | 失败 | 通过率 |
|---|---|---|---|
核心 E2E 测试 (e2e_test.go) |
10 | 0 | 100% |
边界场景测试 (e2e_edge_cases_test.go) |
9 | 8 | 53% |
| 合计 | 19 | 8 | 70% |
| # | 测试用例 | Bug 类型 | 严重度 | HTTP 状态码 |
|---|---|---|---|---|
| 1 | TestVehicleReEntry | 测试框架 / 响应体解析 | 🟡 低 | 200 |
| 2 | TestBlackWhiteListEntryExitBehavior | 黑名单未拦截进场 | 🔴 严重 | 200 |
| 3 | TestVIPExpired | VIP 过期仍免费停车 | 🔴 严重 | 200 |
| 4 | TestNoFeeConfig | 无收费配置默认费率为 0 | 🟡 中等 | 200 |
| 5 | TestShortlistDelete | 后端 panic (nil pointer) | 🔴 严重 | 500 |
| 6 | TestVehicleTypeCRUD | 列表查询返回空 | 🟡 中等 | 200 |
测试用例: TestBlackWhiteListEntryExitBehavior
严重度: 🔴 严重(安全漏洞)
HTTP 状态码: 200 OK
测试步骤:
JingB99999 / RFID RFID_BLACK,关联停车场 ID=1POST /vehicle/entry,传入车牌 JingB99999、RFID RFID_BLACK、停车场 ID=1、车位 ID=1实际结果:
code=0, msg=查询成功INSERT INTO vehicle_record ... plate_number="JingB99999"预期结果:
vehicle_record 入场记录根因分析:
internal/service/vehicle/vehicle.go → VehicleEntry() 方法中 未调用 CheckVehicleShortlist()shortlist.go 中的 CheckVehicleShortlist(rfid string) 方法存在但未被集成到进出场流程中修复建议:
// internal/service/vehicle/vehicle.go -> VehicleEntry()
func (vs *VehicleService) VehicleEntry(ctx context.Context, req *dao.VehicleRecord) (*dao.VehicleRecord, error) {
// TODO: 在创建入场记录前调用黑名单检查
// shortlistResp := shortlist.CheckVehicleShortlist(req.RfidTag)
// if shortlistResp.Code == response.FAIL {
// return nil, errors.New(shortlistResp.Msg)
// }
...
}
测试用例: TestVIPExpired
严重度: 🔴 严重(计费漏洞)
HTTP 状态码: 200 OK
测试步骤:
POST /owner/create 创建 VIP 车主:
JingV00001 / RFID RFID_VIP_EXPPOST /vehicle/entry 让车辆进场POST /vehicle/exit/preview 预览出场费用实际结果:
BUG: Expired VIP still getting free parking! Fee should be > 0预期结果:
根因分析:
is_vip 字段为 true 即触发免单逻辑,忽略了 vip_expire_time 的时间判断CalculateFee() 中增加 VIP 过期检查:if owner.IsVip && owner.VipExpireTime > now修复建议:
// internal/modules/payment/service/service.go -> CalculateFee()
func (ps *PaymentService) CalculateFee(vehicleID uint, entryTime time.Time) (float64, error) {
// 获取车主信息
var owner dao.Owner
db.Where("id = ?", vehicle.OwnerId).First(&owner)
// TODO: 增加 VIP 过期检查
// if owner.IsVip && owner.VipExpireTime != nil && owner.VipExpireTime.After(time.Now()) {
// return 0, nil
// }
...
}
测试用例: TestNoFeeConfig
严重度: 🟡 中等(计费风险)
HTTP 状态码: 200 OK
测试步骤:
DELETE FROM fee_config WHERE vehicle_type_id = ?)JingN00001 / RFID RFID_NOFEE,使用上述无配置的车型POST /vehicle/entry 进场POST /vehicle/exit/preview 预览出场费用实际结果:
BUG: No fee config should use default rate, got fee=0.00预期结果:
根因分析:
internal/modules/payment/service/service.go → CalculateFee() 方法中,当查不到对应车型的收费配置时,直接返回 0修复建议:
// internal/modules/payment/service/service.go -> CalculateFee()
func (ps *PaymentService) CalculateFee(vehicleID uint, entryTime time.Time) (float64, error) {
feeConfig, err := ps.GetFeeConfigByVehicleType(vehicleTypeID)
if err != nil || feeConfig.ID == 0 {
// TODO: 应使用默认费率,而非返回 0
// defaultConfig := ps.GetDefaultFeeConfig()
// feeConfig = defaultConfig
return 0, nil // BUG: 这里应该用默认费率
}
...
}
测试用例: TestVehicleReEntry
严重度: 🟡 低(测试框架兼容性问题)
HTTP 状态码: 200 OK
测试步骤:
JingR00001 / RFID RFID_REENTRYPOST /vehicle/entry 进场POST /vehicle/entry 再次进场(重复入场)实际结果:
unexpected end of JSON inputJSON 解析失败: unexpected end of JSON input | Body:last_entry_time,说明第一次进场实际成功预期结果:
根因分析:
DoPost 方法在处理首次进场请求时,可能因为后端返回了空 body 或 Content-Type 不匹配导致读取失败internal/api/v1/vehicle/enter.go 的响应写入逻辑测试用例: TestShortlistDelete
严重度: 🔴 严重(系统稳定性)
HTTP 状态码: 500 Internal Server Error
测试步骤:
JingDel001 / RFID RFID_DELETEPOST /shortlist/createShortlist 创建黑名单记录GET /shortlist/queryAllShortlists 查询所有名单,获取刚创建的记录 IDDELETE /shortlist/deleteShortlist?id=<ID> 删除该记录实际结果:
HTTP 状态码不匹配: 期望 200, 实际 500runtime error: invalid memory address or nil pointer dereference预期结果:
根因分析:
deleteShortlist 接口存在 空指针引用 问题internal/service/vehicle/shortlist.go 的删除实现测试用例: TestVehicleTypeCRUD
严重度: 🟡 中等(功能缺陷)
HTTP 状态码: 200 OK
测试步骤:
POST /vehicle/type/create 创建自定义车辆类型:
GET /vehicle/type/all 查询所有车辆类型实际结果:
Vehicle type list is empty预期结果:
根因分析:
is_system=false 的记录在查询时被过滤掉了| 优先级 | Bug | 影响范围 | 建议处理 |
|---|---|---|---|
| P0 | 黑名单未拦截 | 安全漏洞,任何黑名单车辆可自由进出 | 立即修复 |
| P0 | 删除接口 Panic | 系统稳定性,可能导致服务崩溃 | 立即修复 |
| P1 | 过期 VIP 免费停车 | 计费漏洞,造成经济损失 | 尽快修复 |
| P1 | 无配置默认费率为 0 | 计费漏洞,无配置车型免费停车 | 尽快修复 |
| P2 | 车辆类型列表查询为空 | 功能缺陷,新增类型无法显示 | 安排修复 |
| P3 | 重复入场响应体为空 | 测试框架兼容性问题 | 低优先级 |
每个 Bug 修复后,应运行以下命令验证:
cd "D:\lq\Smart Parking\lc_garage"
go test ./test/testutil/ -v -timeout 180s
重点关注以下测试用例:
TestBlackWhiteListEntryExitBehavior — 黑名单拦截TestShortlistDelete — 删除接口稳定性TestVIPExpired — VIP 过期计费TestNoFeeConfig — 默认费率回退TestVehicleTypeCRUD — 车辆类型 CRUDTestVehicleReEntry — 重复入场检测以下 19 个测试用例全部通过,核心业务流程正常:
| 序号 | 测试用例 | 说明 |
|---|---|---|
| 1 | TestLoginFlow | 登录流程 |
| 2 | TestSystemManagement | 系统用户管理 |
| 3 | TestParkingInfrastructure | 停车场基础设施 |
| 4 | TestVehicleCRUD | 车辆增删改查 |
| 5 | TestFeeConfig | 收费配置查询 |
| 6 | TestVehicleEntryAndExit | 车辆进出场闭环 |
| 7 | TestBlackWhiteList | 黑白名单基本操作 |
| 8 | TestBlackWhiteListEntryExitBehavior | 白名单进场/出场(黑名单部分失败) |
| 9 | TestOwnerManagement | 车主管理 |
| 10 | TestDashboardMonitoring | 仪表盘数据 |
| 11 | TestExitWithoutEntry | 未入场车辆出场拦截 ✅ |
| 12 | TestPaymentInsufficientAmount | 支付金额不足处理 ✅ |
| 13 | TestFreeDuration | 免费时长内不收费 ✅ |
| 14 | TestDailyCap | 每日封顶费用 ✅ |
| 15 | TestShortlistByPlateOrRFID | 按车牌/RFID 查询名单 ✅ |
| 16 | TestShortlistUpdate | 名单更新 ✅ |
| 17 | TestOwnerVehicleRelationship | 车主关联车辆 ✅ |
| 18 | TestParkingLotCapacity | 停车场容量检查 ✅ |
| 19 | TestBoothCRUD | 岗亭 CRUD ✅ |
| 20 | TestChannelCRUD | 通道 CRUD ✅ |
| 21 | TestDeviceCRUD | 设备 CRUD ✅ |
本报告由自动化测试工具生成