优化钉钉报告样式

This commit is contained in:
chenyongzhiaaron 2023-08-14 10:30:43 +08:00
parent ae7cd13513
commit 76df35c96e
9 changed files with 256 additions and 213 deletions

View File

@ -4,19 +4,16 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="eded71e8-6551-463d-9bd4-cdbb3ffc536c" name="更改" comment="更友好的异常信息输出">
<list default="true" id="eded71e8-6551-463d-9bd4-cdbb3ffc536c" name="更改" comment="增加依赖装饰器,增加自动安装依赖文件,修改报告日志输出边距及颜色">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/OutPut/reports/report.html" beforeDir="false" afterPath="$PROJECT_DIR$/OutPut/reports/report.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cases/cases/test_cases.xlsx" beforeDir="false" afterPath="$PROJECT_DIR$/cases/cases/test_cases.xlsx" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/database/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/database/__init__.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/database/mysql_client.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/database/mysql_client.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/utils/action.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/utils/action.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/core/testRunner.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/core/testRunner.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/utils/decorators.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/utils/decorators.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/utils/install_dependencies.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/utils/install_dependencies.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/validation/comparators.py" beforeDir="false" afterPath="$PROJECT_DIR$/common/validation/comparators.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/common/utils/install_dependencies.py" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/output/reports/history.json" beforeDir="false" afterPath="$PROJECT_DIR$/output/reports/history.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/run.py" beforeDir="false" afterPath="$PROJECT_DIR$/run.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/templates2.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/templates2.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/dingtalk.md" beforeDir="false" afterPath="$PROJECT_DIR$/templates/dingtalk.md" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/weChat.md" beforeDir="false" afterPath="$PROJECT_DIR$/templates/weChat.md" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -55,27 +52,27 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"WebServerToolWindowFactoryState": "false",
"git-widget-placeholder": "master",
"last_opened_file_path": "D:/app/apitest",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/app/apitest&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
},
"keyToStringList": {
"DatabaseDriversLRU": [
"mysql"
&quot;keyToStringList&quot;: {
&quot;DatabaseDriversLRU&quot;: [
&quot;mysql&quot;
]
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="D:\app\apitest" />
@ -237,7 +234,8 @@
<workItem from="1691370512935" duration="75686000" />
<workItem from="1691638175448" duration="3625000" />
<workItem from="1691657355432" duration="5387000" />
<workItem from="1691667714661" duration="8406000" />
<workItem from="1691667714661" duration="8686000" />
<workItem from="1691973725101" duration="6000000" />
</task>
<task id="LOCAL-00001" summary="优化代码">
<option name="closed" value="true" />
@ -367,7 +365,15 @@
<option name="project" value="LOCAL" />
<updated>1691660444913</updated>
</task>
<option name="localTasksCounter" value="17" />
<task id="LOCAL-00017" summary="增加依赖装饰器,增加自动安装依赖文件,修改报告日志输出边距及颜色">
<option name="closed" value="true" />
<created>1691722760750</created>
<option name="number" value="00017" />
<option name="presentableId" value="LOCAL-00017" />
<option name="project" value="LOCAL" />
<updated>1691722760750</updated>
</task>
<option name="localTasksCounter" value="18" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -386,7 +392,8 @@
<MESSAGE value="美化测试报告样式,优化代码" />
<MESSAGE value="更新说明文档" />
<MESSAGE value="更友好的异常信息输出" />
<option name="LAST_COMMIT_MESSAGE" value="更友好的异常信息输出" />
<MESSAGE value="增加依赖装饰器,增加自动安装依赖文件,修改报告日志输出边距及颜色" />
<option name="LAST_COMMIT_MESSAGE" value="增加依赖装饰器,增加自动安装依赖文件,修改报告日志输出边距及颜色" />
</component>
<component name="com.github.evgenys91.machinet.common.dslhistory.DslHistoryState">
<option name="historyDtoById">
@ -407,7 +414,7 @@
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/apitest$load_modules_from_folder.coverage" NAME="load_modules_from_folder 覆盖结果" MODIFIED="1691398471049" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/common/validation" />
<SUITE FILE_PATH="coverage/apitest$run.coverage" NAME="run 覆盖结果" MODIFIED="1691722116466" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/apitest$run.coverage" NAME="run 覆盖结果" MODIFIED="1691979676787" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
<SUITE FILE_PATH="coverage/apitest$Unittest__test_api_py__.coverage" NAME="Unittest (test_api.py 内) 覆盖结果" MODIFIED="1689907531802" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/test_script" />
<SUITE FILE_PATH="coverage/apitest$dingding.coverage" NAME="dingding 覆盖结果" MODIFIED="1691483158998" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/common/notiction" />
<SUITE FILE_PATH="coverage/apitest$assert_dict.coverage" NAME="assert_dict 覆盖结果" MODIFIED="1691034548959" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/common/data_extraction" />

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -74,7 +74,7 @@ class TestRunner:
def __get_reports(self):
"""生成测试报告"""
print("所有用例执行完毕,正在生成测试报告中......")
print("All cases have been executed and the test report is being generated......")
test_result = self.__calculate_test_result()
test_result['runtime'] = '{:.2f} S'.format(time.time() - self.starttime)
test_result["begin_time"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(self.starttime))
@ -97,7 +97,7 @@ class TestRunner:
with open(self.file_path, 'wb') as f:
f.write(report_content.encode('utf8'))
self.test_result = test_result
print(f"测试报告已经生成,报告路径为:{self.file_path}")
print(f"The test report path is: {self.file_path}")
return test_result
def __calculate_test_result(self):
@ -196,12 +196,15 @@ class TestRunner:
for texts in i.failures:
t, content = texts
num += 1
except_info.append("*{}、用例【{}】执行失败*\n失败信息如下:".format(num, t._testMethodDoc))
except_info.append(
"*{}、case【{}】Execution failed*\nThe Execution information is as follows".format(num,
t._testMethodDoc))
except_info.append(content)
for texts in i.errors:
num += 1
t, content = texts
except_info.append("*{}、用例【{}】执行错误*\n错误信息如下:".format(num, t._testMethodDoc))
except_info.append(
"*{}、case【{}】Execution error*\nThe error information is as follows".format(num, t._testMethodDoc))
except_info.append(content)
except_str = "\n".join(except_info)
return except_str

View File

@ -45,9 +45,10 @@ def request_retry_on_exception(retries=2, delay=1.5):
nonlocal e
for i in range(retries):
try:
print(f"| 第{i + 1}次未处理过得请求参数:{args} -- {kwargs}")
response = func(*args, **kwargs)
print(f"| 请求地址 --> {response.request.url}")
print(f"| 请求方法 --> {response.request.method}")
print(f"| 请求头 --> {response.request.headers}")
print(f"| 请求 body --> {response.request.body}")
print(f"| 接口状态--> {response.status_code}")
@ -55,7 +56,7 @@ def request_retry_on_exception(retries=2, delay=1.5):
print(f"| 接口响应--> {response.text}")
except Exception as error:
print(f"| 第{i + 1}次发送请求的参数:{args} -- {kwargs}")
e = error
time.sleep(delay)
else:
@ -119,7 +120,6 @@ def json_data(file_path):
import time
import traceback
def run_count(count, interval, func, *args, **kwargs):
@ -128,8 +128,8 @@ def run_count(count, interval, func, *args, **kwargs):
try:
func(*args, **kwargs)
except Exception as e:
print("====用例执行失败===")
traceback.print_exc()
# print("====用例执行失败===", e)
# traceback.print_exc()
if i + 1 == count:
raise e
else:

View File

@ -1,13 +0,0 @@
#!/usr/bin/env python
# encoding: utf-8
"""
@author: kira
@contact: 262667641@qq.com
@file: install_dependencies.py
@time: 2023/8/9 15:15
@desc: 安装 Pipfile 中的依赖
"""
import subprocess
import sys

File diff suppressed because one or more lines are too long

View File

@ -1,22 +1,25 @@
# **提醒!自动化测试反馈**
# **提醒!自动化测试反馈**
## **请相关同事注意,及时跟进!**
> 项目名称:<font color='info'>{{title}}</font>
> 测试人员:<font color='info'>{{tester}}</font>
> 开始时间:<font color='info'>{{begin_time}}</font>
> 运行时间:<font color='info'>{{runtime}}</font>
> 测试用例总数:<font color='info'>{{all}}</font>
> 测试用例通过率:<font color='info'>{pass_rate}%</font>
> 成功数: <font color='info'>{{success}}</font>
> 失败数:<font color='warning'>{{fail}}</font>
> 跳过数:<font color='info'>{{skip}}, </font>
> 错误数:<font color='comment'>{{error}}</font>
> **--------------------上一次运行结果--------------------**
> 测试用例总数: <font color='info'>{{ history[-1]['all'] }}</font>
> 测试用例通过率:<font color='info'>{{history[-1]['pass_rate']}}%</font>
> 成功数:<font color='info'>{{history[-1]['success']}}</font>
> 失败数:<font color='warning'>{{history[-1]['fail']}}</font>
> 跳过数:<font color='info'>{{history[-1]['skip']}}</font>
> 错误数:<font color='comment'>{{history[-1]['error']}}</font>
> ##### **报告链接:** [jenkins报告,请点击后进入查看](report_url)
#### 项目名称:<font color='#009933'>{{title}}</font><br/>
#### 测试人员:<font color='#009933'>{{tester}}</font><br/>
#### 开始时间:<font color='#009933'>{{begin_time}}</font><br/>
#### 运行时间:<font color='#009933'>{{runtime}}</font><br/>
> 测试用例总数:**<font color='#009933'>{{all}}</font><br/>**
> 测试用例通过率:**<font color='#009933'>{{pass_rate}}%</font><br/>**
> 成功数: **<font color='#009933'>{{success}}</font><br/>**
> 失败数:**<font color='#FF6666'>{{fail}}</font><br/>**
> 跳过数:**<font color='#009999'>{{skip}} </font><br/>**
> 错误数:**<font color='#CC0066'>{{error}}</font><br/>**
**----------------上一次运行结果----------------**<br/>
> 测试用例总数: **<font color='#009933'>{{ history[-1]['all'] }}</font><br/>**
> 测试用例通过率:**<font color='#009933'>{{history[-1]['pass_rate']}}%</font><br/>**
> 成功数:**<font color='#009933'>{{history[-1]['success']}}</font><br/>**
> 失败数:**<font color='#FF6666'>{{history[-1]['fail']}}</font><br/>**
> 跳过数:**<font color='#009999'>{{history[-1]['skip']}}</font><br/>**
> 错误数:**<font color='#CC0066'>{{history[-1]['error']}}</font><br/>**
##### **报告链接:** [jenkins报告,请点击后进入查看](report_url)

View File

@ -6,7 +6,7 @@
> 开始时间:<font color='info'>{{begin_time}}</font>
> 运行时间:<font color='info'>{{runtime}}</font>
> 测试用例总数:<font color='info'>{{all}}</font>
> 测试用例通过率:<font color='info'>{pass_rate}%</font>
> 测试用例通过率:<font color='info'>{{pass_rate}}%</font>
> 成功数: <font color='info'>{{success}}</font>
> 失败数:<font color='warning'>{{fail}}</font>
> 跳过数:<font color='info'>{{skip}}, </font>