feat(core): 增强 Exchange,实现智能变量替换与类型保持
- 优化 conftest.py 增加异常日志记录和测试报告环境信息 - 其他优化
This commit is contained in:
@@ -14,6 +14,8 @@ import logging
|
||||
import allure
|
||||
from pathlib import Path
|
||||
from dataclasses import dataclass
|
||||
|
||||
from conftest import execution_context
|
||||
from core import settings
|
||||
from core.executor import WorkflowExecutor
|
||||
from pydantic import ValidationError
|
||||
@@ -142,7 +144,7 @@ class CaseGenerator:
|
||||
method_name = f"test_{index:03d}_{safe_title}"
|
||||
print(method_name)
|
||||
setattr(target_cls, method_name, dynamic_test_method)
|
||||
print(target_cls.__dict__)
|
||||
# print(target_cls.__dict__)
|
||||
logger.debug(f"Successfully registered: {method_name}")
|
||||
|
||||
@staticmethod
|
||||
@@ -150,8 +152,7 @@ class CaseGenerator:
|
||||
"""封装具体的 pytest 执行节点"""
|
||||
case_template = entity.step_data
|
||||
context = entity.row_context
|
||||
|
||||
def build_actual_case(instance: TestTemplateBase, api_env):
|
||||
def build_actual_case(instance: TestTemplateBase, execution_context):
|
||||
# --- 1. 动态设置 Allure 报告属性 ---
|
||||
|
||||
allure.dynamic.epic(case_template.epic or settings.allure_epic)
|
||||
@@ -161,7 +162,7 @@ class CaseGenerator:
|
||||
# 日志记录 (利用 instance 标注来源)
|
||||
logger.info(f"[Runner] Class: {instance.__class__.__name__} | Case: {title}")
|
||||
try:
|
||||
WorkflowExecutor.perform(case_template, api_env, context=context)
|
||||
WorkflowExecutor.perform(case_template, execution_context, context=context)
|
||||
|
||||
except Exception as e:
|
||||
# 可以在这里记录更详细的运行上下文快照
|
||||
@@ -176,4 +177,4 @@ if __name__ == '__main__':
|
||||
|
||||
# print(CaseDataLoader.get_all_cases(TEST_CASE_DIR))
|
||||
# --- 引导执行 ---
|
||||
CaseGenerator.build_and_register(TestTemplateBase, settings.TEST_CASE_DIR)
|
||||
CaseGenerator.build_and_register(TestTemplateBase, settings.TEST_CASE_DIR)
|
||||
Reference in New Issue
Block a user