Userdefined Methods

Table of Contents

When you’re writing high functional scripts, you may get in trouble with the complexity of the code. Many lines of code and repeating code-parts can be difficult to read and also to maintain.

Userdefined methods make you capable of centrally managing parts of your scripts-code in C#-methods. Methods are basically a language-feature of C#/.NET. But we give you a way to manage them in a central place.

Creating a Userdefined Methods

  1. Open “Environment” -> “Userdefined Methods” in the main navigation of BiG EVAL.
  2. Click on the button “Create Userdefined Method”.
  3. Modify the presented template to your needs using the C# language features.
  4. Click on “Save Userdefined Method”.

The following example shows a userdefined method that allows to send a message to a slack-channel.

Please note the Imports we did. This allows to use these .NET namespaces directly in your userdefined method code.

The full code of this userdefined method can be found in this article.

How to use a Userdefined Method in a Script

You can use a userdefined method in your C# scripts (testsuite-script or testcase-script) like a normal C# method. So if you defined a method called “myMethod” with two string-parameters, it could look like this:

myMethod("param A", "param B");

Using the Slack-Method in the example above is a little bit different, because it is an asynchronous method. You can do it like this:

await PostToSlackAsync("This is my message.");