Dynamic test data using Global Variable

Hi All,

I am wondering how to pass the test data from a Global Variable which increases it’s value by it’s own whenever I run the test case. E.g. I want to enter the username to be entered as

Test 1
Test 2
Test 3
.
.
.
Test n, each time I run the test case. How do I define that under Global variable?

I use only Global Variable to pass my test data and do not use excel or csv. Please help.

Thanks

I made a Test Case TC1:


import internal.GlobalVariable as GlobalVariable

// we assume GlobalVariable.SEQ is defined with initial value 0

println GlobalVariable.SEQ

GlobalVariable.SEQ += 1
println GlobalVariable.SEQ

GlobalVariable.SEQ += 1
println GlobalVariable.SEQ

When I ran TC1, I got:

2021-02-15 23:01:40.609 INFO  c.k.katalon.core.main.TestCaseExecutor   - START Test Cases/incrementGlobalVariable
2021-02-15 23:01:41.696 DEBUG testcase.incrementGlobalVariable         - 1: println(SEQ)
0
2021-02-15 23:01:41.891 DEBUG testcase.incrementGlobalVariable         - 2: SEQ += 1
2021-02-15 23:01:41.894 DEBUG testcase.incrementGlobalVariable         - 3: println(SEQ)
1
2021-02-15 23:01:41.912 DEBUG testcase.incrementGlobalVariable         - 4: SEQ += 1
2021-02-15 23:01:41.917 DEBUG testcase.incrementGlobalVariable         - 5: println(SEQ)
2
2021-02-15 23:01:41.932 INFO  c.k.katalon.core.main.TestCaseExecutor   - END Test Cases/incrementGlobalVariable

This shows that you can change the value of a GlobalVariable by script.

Thank you for the reply. The above example works if the Value Type is number but I want to concatenate with String. When I set the Value Type to string, I am geting the following output.

<
2021-02-18 16:01:32.552 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/New Test Case
2021-02-18 16:01:33.594 DEBUG testcase.New Test Case - 1: println(username)
test
2021-02-18 16:01:33.817 DEBUG testcase.New Test Case - 2: username += 1
2021-02-18 16:01:33.827 DEBUG testcase.New Test Case - 3: println(username)
test1
2021-02-18 16:01:33.842 DEBUG testcase.New Test Case - 4: username += 1
2021-02-18 16:01:33.847 DEBUG testcase.New Test Case - 5: println(username)
test11
2021-02-18 16:01:33.852 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/New Test Case

The username I create should be incremented with the numbers. Example, test+1@test.com
test+2@test.com

an so on. Also I want to store this value in a separate Global Variable. Please help.

Thanks

Can somebody help me on this please?

Thanks