代码之家  ›  专栏  ›  技术社区  ›  NarendraR TheSociety

如何在TestNG中根据条件排除组?

  •  1
  • NarendraR TheSociety  · 技术社区  · 6 年前

    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>
    

    回归 专业排除 两个都分组。我不想执行这个,但剩下的场景只有 回归 组。

    2 回复  |  直到 6 年前
        1
  •  1
  •   user861594    6 年前

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

    • 范围-烟雾、回归
    • 模块-功能模块1,FM2
    • 频道-Web、API、移动

    等。。。

    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编写测试用例,那么可以使用 @MetaData include exclude 属性值如下:

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

    scope 谁的价值是 REGRESSION 以及 feature 谁的价值是 PRO_EXCLUDE . 请参考 documentation

    注意 com.qmetry.qaf.automation.testng.pro.QAFMethodSelector 在xml配置文件、ant testng目标或maven pom中。群也被qaf视为元数据之一。

        2
  •  0
  •   NarendraR TheSociety    6 年前

    以下是为我工作的条件:

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

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