-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrun-tests.sh
More file actions
executable file
·113 lines (97 loc) · 3.21 KB
/
run-tests.sh
File metadata and controls
executable file
·113 lines (97 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/bash
<<<<<<< HEAD
# 颜色定义
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} HPlus Validate 测试套件${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
# 检查 vendor 目录
if [ ! -d "vendor" ]; then
echo -e "${YELLOW}正在安装依赖...${NC}"
composer install
fi
# 运行所有测试
if [ "$1" == "" ]; then
echo -e "${YELLOW}运行所有测试...${NC}"
./vendor/bin/phpunit --colors=always
# 运行单元测试
elif [ "$1" == "unit" ]; then
echo -e "${YELLOW}运行单元测试...${NC}"
./vendor/bin/phpunit --colors=always --testsuite "Unit Tests"
# 运行功能测试
elif [ "$1" == "feature" ]; then
echo -e "${YELLOW}运行功能测试...${NC}"
./vendor/bin/phpunit --colors=always --testsuite "Feature Tests"
# 运行性能测试
elif [ "$1" == "performance" ]; then
echo -e "${YELLOW}运行性能测试...${NC}"
./vendor/bin/phpunit --colors=always --testsuite "Performance Tests"
# 运行代码覆盖率测试
elif [ "$1" == "coverage" ]; then
echo -e "${YELLOW}运行代码覆盖率测试...${NC}"
./vendor/bin/phpunit --colors=always --coverage-html build/coverage
# 运行指定的测试文件
elif [ "$1" == "file" ]; then
if [ "$2" == "" ]; then
echo -e "${RED}错误: 请指定测试文件${NC}"
echo "使用方式: ./run-tests.sh file tests/Unit/ValidationAspectTest.php"
exit 1
fi
echo -e "${YELLOW}运行测试文件: $2${NC}"
./vendor/bin/phpunit --colors=always "$2"
# 显示帮助信息
elif [ "$1" == "help" ]; then
echo "使用方式: ./run-tests.sh [选项]"
echo ""
echo "选项:"
echo " (无) - 运行所有测试"
echo " unit - 仅运行单元测试"
echo " feature - 仅运行功能测试"
echo " performance - 仅运行性能测试"
echo " coverage - 运行代码覆盖率测试"
echo " file <路径> - 运行指定的测试文件"
echo " help - 显示此帮助信息"
echo ""
echo "示例:"
echo " ./run-tests.sh"
echo " ./run-tests.sh unit"
echo " ./run-tests.sh file tests/Unit/ValidationAspectTest.php"
exit 0
else
echo -e "${RED}错误: 未知选项 '$1'${NC}"
echo "使用 './run-tests.sh help' 查看帮助"
exit 1
fi
# 检查测试结果
if [ $? -eq 0 ]; then
echo ""
echo -e "${GREEN}✓ 所有测试通过!${NC}"
exit 0
else
echo ""
echo -e "${RED}✗ 测试失败${NC}"
exit 1
fi
=======
echo "==================================="
echo "Hyperf-Plus Validate 测试套件"
echo "==================================="
echo
echo "正在安装测试依赖..."
composer install --dev
echo
echo "运行单元测试..."
echo "==================================="
./vendor/bin/phpunit -c phpunit.xml --colors=always
echo
echo "生成代码覆盖率报告..."
echo "==================================="
./vendor/bin/phpunit -c phpunit.xml --colors=always --coverage-html tests/coverage --coverage-text
echo
echo "测试完成!"
echo "覆盖率报告已生成在: tests/coverage/index.html"
>>>>>>> 6490b4a99ecb2dc9d88003e0d659cdcb6a6dc610