1

So I'm trying to use something ancient like the 4Test language in SilkTest in a somewhat modern manner. I have several similar tests which differ in only a part of the code. I would like to create an infrastructure function which would do the boilerplate stuff and then just call different functions for different tests. Like a callback function let's say.

So I would like to do something like that:

testcase A(Function F)
    do some stuff
    F()
    do other stuff

Has anyone done this? How should I do it?

4

1 回答 1

1

所以我找到了一个解决方案,出于文档原因,我将其发布在这里。

当一个人想要将函数作为参数传递时,他们必须将函数的名称作为字符串传递,然后使用以下结构调用它

@(functionNameString)()

所以代码就像

void someFunction()
    Print("Hello World!")

@("someFunction")()

这也适用于对象的方法。

于 2016-04-06T13:32:16.860 回答