testbase.report
Package¶
测试报告
-
class
testbase.report.
EmptyTestReport
(result_factory_func=None)¶ 基类:
testbase.report.TestReportBase
不输出测试报告
-
classmethod
get_parser
()¶ 获取命令行参数解析器(如果实现)
返回: 解析器对象 返回类型: argparse.ArgumentParser
-
get_testresult_factory
()¶ 获取对应的TestResult工厂 :returns ITestResultFactory
-
classmethod
parse_args
(args_string)¶ 通过命令行参数构造对象
返回: 测试报告 返回类型: cls
-
classmethod
-
class
testbase.report.
EmptyTestResultFactory
(result_factory_func=None)¶ 基类:
testbase.report.ITestResultFactory
测试结果工厂
-
create
(testcase)¶ 创建TestResult对象 :param testcase: 测试用例 :type testcase: TestCase :return TestResult
-
dumps
()¶ 序列化 :return picklable object
-
loads
(buf)¶ 反序列化 :param buf: dumps返回的序列化后的数据 :type buf: object
-
-
class
testbase.report.
HtmlTestReport
(title='xe8xb0x83xe8xafx95xe6xb5x8bxe8xafx95', displays=['failed', 'error'])¶ 基类:
testbase.report.JSONTestReportBase
html test report
-
end_report
()¶ 结束测试执行 :param passed: 测试是否通过 :type passed: boolean
-
classmethod
get_parser
()¶ 获取命令行参数解析器(如果实现)
返回: 解析器对象 返回类型: argparse.ArgumentParser
-
get_testresult_factory
()¶ 获取对应的TestResult工厂 :returns ITestResultFactory
-
classmethod
parse_args
(args_string)¶ 通过命令行参数构造对象
返回: 测试报告 返回类型: cls
-
-
class
testbase.report.
HtmlTestResultFactory
¶ 基类:
testbase.report.ITestResultFactory
html test result factory
-
create
(testcase)¶ 创建TestResult对象 :param testcase: 测试用例 :type testcase: TestCase :return TestResult
-
-
class
testbase.report.
ITestReport
¶ 基类:
object
测试报告接口
-
begin_report
()¶ 开始测试执行
-
critical
(tag, msg, record=None)¶ 记录一个CRITICAL日志 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type tag: string :type msg: string :type record: dict
-
debug
(tag, msg, record=None)¶ 记录一个DEBUG日志 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type tag: string :type msg: string :type record: dict
-
end_report
()¶ 结束测试执行
参数: passed (boolean) -- 测试是否通过
-
error
(tag, msg, record=None)¶ 记录一个ERROR日志 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type tag: string :type msg: string :type record: dict
-
classmethod
get_parser
()¶ 获取命令行参数解析器(如果实现)
返回: 解析器对象 返回类型: argparse.ArgumentParser
-
get_testresult_factory
()¶ 获取对应的TestResult工厂
:returns ITestResultFactory
-
info
(tag, msg, record=None)¶ 记录一个INFO日志 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type tag: string :type msg: string :type record: dict
-
is_passed
()¶ 报告中所有用例是否都通过
返回: boolean
-
log_filtered_test
(loader, testcase, reason)¶ 记录一个被过滤的测试用例
参数: - loader (TestLoader) -- 用例加载器
- testcase (TestCase) -- 测试用例
- reason (str) -- 过滤原因
-
log_load_error
(loader, name, error)¶ 记录一个加载失败的用例或用例集
参数: - loader (TestLoader) -- 用例加载器
- name (str) -- 名称
- error (str) -- 错误信息
-
log_loaded_tests
(loader, testcases)¶ 记录加载成功的用例
参数: - loader (TestLoader) -- 用例加载器
- testcases (list) -- 测试用例列表
-
log_record
(level, tag, msg, record)¶ 增加一个记录
参数: - level (string) -- 日志级别
- msg (string) -- 日志消息
- tag (string) -- 日志标签
- record (dict) -- 日志记录信息
-
log_resource
(res_type, resource)¶ 记录测试使用的资源
参数: - res_type (str) -- 资源类型
- resource (dict) -- 资源详情
-
log_test_result
(testcase, testresult)¶ 记录一个测试结果
参数: - testcase (TestCase) -- 测试用例
- testresult (TestResult) -- 测试结果
-
log_test_target
(test_target)¶ 记录被测对象
参数: test_target (any) -- 被测对象详情
-
classmethod
parse_args
(args_string)¶ 通过命令行参数构造对象
返回: 测试报告 返回类型: cls
-
warning
(tag, msg, record=None)¶ 记录一个WARN日志 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type tag: string :type msg: string :type record: dict
-
-
class
testbase.report.
ITestResultFactory
¶ 基类:
object
TestResult工厂接口
-
create
(testcase)¶ 创建TestResult对象 :param testcase: 测试用例 :type testcase: TestCase :return TestResult
-
dumps
()¶ 序列化 :return picklable object
-
loads
(buf)¶ 反序列化 :param buf: dumps返回的序列化后的数据 :type buf: object
-
-
class
testbase.report.
JSONTestReport
(fd, title='xe8xb0x83xe8xafx95xe6xb5x8bxe8xafx95')¶ 基类:
testbase.report.JSONTestReportBase
JSON格式的测试报告
-
end_report
()¶ 结束测试执行
-
classmethod
get_parser
()¶ 获取命令行参数解析器(如果实现)
返回: 解析器对象 返回类型: argparse.ArgumentParser
-
get_testresult_factory
()¶ 获取对应的TestResult工厂 :returns ITestResultFactory
-
classmethod
parse_args
(args_string)¶ 通过命令行参数构造对象
返回: 测试报告 返回类型: cls
-
-
class
testbase.report.
JSONTestReportBase
(title='xe8xb0x83xe8xafx95xe6xb5x8bxe8xafx95')¶ 基类:
testbase.report.TestReportBase
JSON格式的测试报告基类
-
begin_report
()¶ 开始测试执行
-
end_report
()¶ 结束测试执行 :param passed: 测试是否通过 :type passed: boolean
-
log_filtered_test
(loader, testcase, reason)¶ 记录一个被过滤的测试用例 :param loader: 用例加载器 :type loader: TestLoader :param testcase: 测试用例 :type testcase: TestCase :param reason: 过滤原因 :type reason: str
-
log_load_error
(loader, name, error)¶ 记录一个加载失败的用例或用例集 :param loader: 用例加载器 :type loader: TestLoader :param name: 名称 :type name: str :param error: 错误信息 :type error: str
-
log_record
(level, tag, msg, record)¶ 增加一个记录 :param level: 日志级别 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type level: string :type tag: string :type msg: string :type record: dict
-
log_test_result
(testcase, testresult)¶ 记录一个测试结果 :param testcase: 测试用例 :type testcase: TestCase :param testresult: 测试结果 :type testresult: TestResult
-
-
class
testbase.report.
JSONTestResultFactory
¶ 基类:
testbase.report.ITestResultFactory
JSON形式TestResult工厂
-
create
(testcase)¶ 创建TestResult对象 :param testcase: 测试用例 :type testcase: TestCase :return TestResult
-
-
class
testbase.report.
LineTestListOutput
(output_file)¶ 基类:
testbase.report.TestListOutputBase
output test list as single line
-
class
testbase.report.
StreamTestListOutput
(output_file)¶ 基类:
testbase.report.TestListOutputBase
stream output
-
class
testbase.report.
StreamTestReport
(stream=<open file '<stdout>', mode 'w'>, error_stream=<open file '<stderr>', mode 'w'>, output_testresult=False, output_summary=True)¶ 基类:
testbase.report.TestReportBase
流形式的测试报告
-
begin_report
()¶ 开始测试执行
-
end_report
()¶ 结束测试执行 :param passed: 测试是否通过 :type passed: boolean
-
classmethod
get_parser
()¶ 获取命令行参数解析器(如果实现)
返回: 解析器对象 返回类型: argparse.ArgumentParser
-
get_testresult_factory
()¶ 获取对应的TestResult工厂 :returns ITestResultFactory
-
log_filtered_test
(loader, testcase, reason)¶ 记录一个被过滤的测试用例 :param loader: 用例加载器 :type loader: TestLoader :param testcase: 测试用例 :type testcase: TestCase :param reason: 过滤原因 :type reason: str
-
log_load_error
(loader, name, error)¶ 记录一个加载失败的用例或用例集 :param loader: 用例加载器 :type loader: TestLoader :param name: 名称 :type name: str :param error: 错误信息 :type error: str
-
log_record
(level, tag, msg, record={})¶ 增加一个记录 :param level: 日志级别 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type level: string :type tag: string :type msg: string :type record: dict
-
log_test_result
(testcase, testresult)¶ 记录一个测试结果 :param testcase: 测试用例 :type testcase: TestCase :param testresult: 测试结果 :type testresult: TestResult
-
classmethod
parse_args
(args_string)¶ 通过命令行参数构造对象
返回: 测试报告 返回类型: cls
-
-
class
testbase.report.
StreamTestResultFactory
(stream)¶ 基类:
testbase.report.ITestResultFactory
流形式TestResult工厂
-
create
(testcase)¶ 创建TestResult对象 :param testcase: 测试用例 :type testcase: TestCase :return TestResult
-
dumps
()¶ 序列化 :return picklable object
-
loads
(buf)¶ 反序列化 :param buf: dumps返回的序列化后的数据 :type buf: object
-
-
class
testbase.report.
TestListOutputBase
(output_file)¶ 基类:
object
base class of test case list output
-
class
testbase.report.
TestReportBase
¶ 基类:
testbase.report.ITestReport
TestReport基类
-
is_passed
()¶ 报告中是否所有用例都通过,兼容已有EmptyTestReport,若用例数为0,也认为不通过
返回: boolean
-
-
class
testbase.report.
XMLTestReport
¶ 基类:
testbase.report.TestReportBase
XML形式的测试报告
-
begin_report
()¶ 开始测试执行
-
end_report
()¶ 结束测试执行 :param passed: 测试是否通过 :type passed: boolean
-
classmethod
get_parser
()¶ 获取命令行参数解析器(如果实现)
返回: 解析器对象 返回类型: argparse.ArgumentParser
-
get_testresult_factory
()¶ 获取对应的TestResult工厂 :returns ITestResultFactory
-
log_filtered_test
(loader, testcase, reason)¶ 记录一个被过滤的测试用例 :param loader: 用例加载器 :type loader: TestLoader :param testcase: 测试用例 :type testcase: TestCase :param reason: 过滤原因 :type reason: str
-
log_load_error
(loader, name, error)¶ 记录一个加载失败的用例或用例集 :param loader: 用例加载器 :type loader: TestLoader :param name: 名称 :type name: str :param error: 错误信息 :type error: str
-
log_record
(level, tag, msg, record={})¶ 增加一个记录 :param level: 日志级别 :param msg: 日志消息 :param tag: 日志标签 :param record: 日志记录信息 :type level: string :type tag: string :type msg: string :type record: dict
-
log_test_result
(testcase, testresult)¶ 记录一个测试结果 :param testcase: 测试用例 :type testcase: TestCase :param testresult: 测试结果 :type testresult: XmlResult
-
classmethod
parse_args
(args_string)¶ 通过命令行参数构造对象
返回: 测试报告 返回类型: cls
-
-
class
testbase.report.
XMLTestResultFactory
¶ 基类:
testbase.report.ITestResultFactory
XML形式TestResult工厂
-
create
(testcase)¶ 创建TestResult对象 :param testcase: 测试用例 :type testcase: TestCase :return TestResult
-