1

如何使用自定义标签选择要运行的场景?

对于 Eaxmple,以下是功能文件

Feature:my example feature 

@Test_Name:sample @abc:1234 @sd:567

Scenario: Example scenario
 Given my Name is sample
 When my Name is whensample
 Then  my Name is endsample

我有多个功能文件,每个功能文件都有很多场景。场景标签与上面提到的方式类似。我正在尝试运行场景

   behave -t Test_Name --> to run all files
   behave -t abcd --> run specific scenario
   behave -t 1234 --> run specific scenario

请建议是否有任何方法可以做到这一点。

4

2 回答 2

1

为@testtag1、@testtag2 等场景添加标签,如下所示


Feature: showing off behave
  @testtag1
  Scenario: run a simple test
     Given we have behave installed
      when we implement a test
      then behave will test it for us!

  @testtag2
  Scenario: run a simple test2
     Given we have behave installed
      when we implement a test
      then behave will test it for us!

@testtag1
  Scenario: run a simple test3
     Given we have behave installed
      when we implement a test
      then behave will test it for us!

运行命令

behave --tags=testtag1

测试标签为 testtag1 的场景

于 2016-04-20T03:28:03.627 回答
0

由 Surbhi 创建于 09-07-2020

Feature: # 在此处输入功能名称


@chrome
场景:
给定用户使用 chrome 在 python 上测试 selenium


@ff
场景:
给定用户使用 firefox 在 python 上测试 selenium

UseCommand :
在参数配置中表现 -t=chrome 和表现 -t=ff

或者您也可以使用:行为 --tags=@chrome 在此处输入图像描述

于 2020-07-10T12:35:50.560 回答