从Groovy的内部设置方法调用封闭/方法

时间:2018-06-26 14:57:50

标签: groovy katalon-studio

由于某种原因,设置方法无法识别其之前的闭包,因为当将此代码放入测试套件并运行时,它会抛出 MissingMethodException关于我要调用的闭包:

int initialNumberOfRows = 0

def findRowCount = {

    initialNumberOfRows = 5
}

/**
 * Some methods below are samples for using SetUp/TearDown in a test suite.
 */
/**
 * Sets up test environment.
 */
@SetUp(skipped = false) // Please change skipped to be false to activate this method.
def setUp() {
    //  login and select the test company first
    WebUI.callTestCase(findTestCase('Test Cases/TestCompanySelectGoesToDashboard'), [('shouldLogout') : false, ('shouldCloseBrowser') : false])
    //  go to the "Discounts" page
    WebUI.click(findTestObject('PageMenuOptions/a_Discounts'))
    //  determine the row count
    WebUI.delay(5)
    findRowCount()
}

我运行该代码,并收到以下异常消息:

groovy.lang.MissingMethodException: No signature of method: DiscountsSuite.findRowCount() is applicable for argument types: () values: []

到目前为止,闭包是一个存根,但是将用于获取行数,之后我们将删除该行作为测试套件的清理工作(我通过测试套件进行行的创建,我必须进行清理起来!)

0 个答案:

没有答案
相关问题