1

我在登录模块中有大约 10 个测试用例。我必须在 Staging 和 Product 环境中执行测试,但在 Product 环境中,需要排除一些特定的测试用例,这些测试用例需要在应用程序中插入一些虚拟数据。为此,我PRO_EXCLUDE在我的场景中添加了一个组名。

请参阅下面的示例,其中包含我在执行时需要排除的组合组名。

SCENARIO: verify login landing page
META-DATA: {"TestCase_ID":"BP_L&R_001","description":"verify login landing page ","groups":["REGRESSION","PRO_EXCLUDE"]}    
    Given user is on homepage
    When clicks on login link
    Then verify page title text with title '${loginpage.title}'
END

其余方法只有一组,即REGRESSION

我已经按照以下方式配置了测试

<test name="Login" enabled="true">
    <method-selectors>
        <method-selector>
            <script language="beanshell"><![CDATA[ return groups.containsKey("REGRESSION") && groups.containsKey("PRO_EXCLUDE");]]></script>
        </method-selector>
    </method-selectors>
    <parameter name="scenario.file.loc" value="scenarios/login.bdd" />

    <classes>
        <class name="com.qmetry.qaf.automation.step.client.text.BDDTestFactory"></class>
    </classes>
</test>

这将执行同时具有REGRESSIONPRO_EXCLUDE分组的场景。我不想执行这个,但其余的场景只有REGRESSION组。

4

2 回答 2

1

更好的方法是利用 qaf 的元数据特性。根据这一点,而不是添加多个组,而是根据性质对它们进行分类。例如:

  • 范围 - 烟雾,回归
  • 模块 - FunctionlModule1, FM2
  • 渠道 - 网络、API、移动

ETC...

您需要为您的 AUT 定义并在场景中设置为元数据。

SCENARIO: verify login landing page
META-DATA: {"TestCase_ID":"BP_L&R_001","description":"verify login landing page ","scope":"REGRESSION","feature":"PRO_EXCLUDE"]}    
    Given user is on homepage
    When clicks on login link
    Then verify page title text with title '${loginpage.title}'
END

如果您在 java 中编写测试用例,您可以使用@MetaDataon test 方法来设置测试用例元数据。include您可以通过设置适当的exclude属性值来使用元数据过滤器,如下所示:

include= {'scope': ['REGRESSION'], 'feature': ['PRO_EXCLUDE']}

它将包括具有scope值为REGRESSION AND feature的元数据的测试用例/场景PRO_EXCLUDE。请参阅文档以获取更多使用示例。

注意com.qmetry.qaf.automation.testng.pro.QAFMethodSelector:要正确使用此功能,您必须在 xml 配置文件或 ant testng 目标或 maven pom 中添加来自 qaf 的方法选择器组也被 qaf 视为元数据之一。

于 2018-09-21T19:08:03.353 回答
0

以下条件为我工作:

<method-selectors>
    <method-selector>
        <script language="beanshell"><![CDATA[ return groups.containsKey("REGRESSION") && (!groups.containsKey("PRO_EXCLUDE"));]]></script>
    </method-selector>
</method-selectors>

进一步的解决方案将不胜感激。

于 2018-09-21T07:39:52.123 回答