I would like to set some global values that I can use in my testcases, like todays date. I managed to do it on a testcase-basis it with a little help from stackoverflow:
def date = new Date()
sdf = new SimpleDateFormat("dd/MM/yyyy")
Now my question is: where can I put code like that so that it’s “globally” available? For now I have added the code to the testcases themselves but for obvious reasons I’d like it to be in a central location.
Thanks in advance!
So you have profiles for global variables, which allows you to create variables that can be used across all test cases when with multiple variations for each profile. This is good for using different URLs, logins etc for different test systems.
However, what you need is keywords. This acts as a libary where you can store code that you want to reuse across your whole project. As this is a function not a variable, you will need to store it here. You can then just call the method in each test case you require.
Thanks for the quick answer. I will try with a custom keyword and report back.
Edit: I created a custom keyword for the current date and even added arguments to change the output format => it’s working nicely