全局变量-Katalon Studio [英] Global Variables - Katalon Studio

查看:200
本文介绍了全局变量-Katalon Studio的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与Cucumber& Katalon Studio中的Groovy。

I am working with Cucumber & Groovy in Katalon Studio.

我在Cucumber中有十个特征文件行以及相应的步骤定义。

I have ten feature file lines in Cucumber and corresponding step definitions.

黄瓜功能文件的第一步具有指示符,如果在第一行中使用 NO RUN参数传递了该行,则该测试用例不应运行,而应移至下一个测试用例。

In my cucumber feature file first step has the indicator where if the first line is passed with the parameter with "NO RUN", the test case should not run and it should be moved to the next test case.

所以,我想,我将使用Global变量指标,在测试中可以处理并分配值。我看到了,可以在执行配置文件下创建全局变量(RUN INDICATOR)。但是,不确定是否需要在测试脚本中使用该变量或进行引用。

So, I thought, I will use the Global variable indicator where I can handle in the test and assign the values. I see that and could create the Global Variable (RUN INDICATOR) under the Execution profile. But, not sure how I need to use that variable in the test script or refer.

有人可以提供有关此内容的信息以继续进行吗?

Can someone please provide the inputs on this to proceed further ?

步骤定义

@Given("running indicator flag (.*)")
def run_indicator_flag(String ind1)  {
    println "Passing Indicator " + ind1
    assert ((ind1!='') || (ind1!='N'))
    WebUI.openBrowser('', FailureHandling.STOP_ON_FAILURE)
}


推荐答案

您可以使用测试侦听器来做到这一点。

You can use test listeners to do that.


  1. 创建具有空字符串值的全局变量(在实际运行测试用例/套件之前,需要执行此操作):



GlobalVariable.RUN_INDICATOR = ''

您将手动或之前更新其值测试会将其更新为您想要的任何值。

You will update its value either manually or preceding test will update it to whatever value you wish.


  1. 创建具有以下代码的测试监听器



@BeforeTestCase
def sampleBeforeTestCase(TestCaseContext testCaseContext) {
    if(GlobalVariable.RUN_INDICATOR=='NO RUN'){
        testCaseContext.skipThisTestCase()
        println "Test Case skipped"
    }
}

如果 GlobalVariable.RUN_INDICATOR 设置为否 RUN,该测试用例将被跳过,测试套件将继续进行下一个。

If the GlobalVariable.RUN_INDICATOR is set to 'NO RUN', this test case will be skipped and the test suite will continue with the next one.

这篇关于全局变量-Katalon Studio的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆