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?

Johnbo
  • 498
  • 6
  • 16
Kokozaurus
  • 639
  • 7
  • 22

1 Answers1

1

So I have found a solution and I'm posting it here for documentation reasons.

When a person wants to pass a function as an argument, they have to pass the name of the function as string, and then call it with the following structure

@(functionNameString)()

So the code would be like

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

@("someFunction")()

This also works with methods of objects.

Kokozaurus
  • 639
  • 7
  • 22