You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Taurus中include-scenario块场景级属性使用问题求助

解决Taurus复用登录场景并传递专属账号的问题

首先,你当前的配置存在几个关键问题导致报错,以下是具体修正方案:

1. 修正拼写错误

第一个配置块里的include-scenrio是拼写错误,正确写法为include-scenario。YAML对关键字拼写要求严格,这个语法错误直接触发了Config error: Wrong request。

2. 调整场景结构

你将include-scenario: login和include-scenario: feature1作为独立顶级节点,Taurus无法识别它们属于同一功能测试流程,也就无法把属性正确关联到登录场景。

正确配置示例

把每个功能的登录流程和功能测试脚本归到同一个场景下,同时设置专属账号属性:

scenarios:
  feature1-test:
    include-scenarios:
      - login
      - feature1
    properties:
      Username: Feature_user1
      Password: Feature_pswd1
  feature2-test:
    include-scenarios:
      - login
      - feature2
    properties:
      Username: Feature_user2
      Password: Feature_pswd2

或者用顶级场景列表写法:

- scenario: feature1-flow
  include-scenarios:
    - login
    - feature1
  properties:
    Username: Feature_user1
    Password: Feature_pswd1
- scenario: feature2-flow
  include-scenarios:
    - login
    - feature2
  properties:
    Username: Feature_user2
    Password: Feature_pswd2

3. 修正属性引用方式

你使用的${${__P(Username)}}是错误的嵌套变量写法,完全没必要。在JMeter登录脚本里,直接用${__P(Username,)}即可获取场景级的Username属性,密码同理用${__P(Password,)}(第二个空字符串参数用于避免属性未定义时报错)。

额外注意事项

  • YAML对缩进敏感,确保properties下的每个属性(Username、Password)都有正确缩进(通常相对于properties缩进2个空格)。
  • 确认login场景的JMeter脚本中,登录请求的用户名、密码参数已替换为上述属性引用。

内容的提问来源于stack exchange,提问作者born2Learn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 14:30:04