Can I carry a variable generated in a test case to other test cases?

Hi, so i have an odd question. Im creating something called a task, in which has a unique Id so upon deletion or rerunning a test, that task will have its id changed upon creation. I can get the id from the url which is great. In another test case however, I need to click an edit button, but again the task Id keeps changing i deleted. For example Task ID = 2050. The button has editTask2050 on it.

What I hoped to do is pass the variable taskID which holds 2050 for example from the one test case to the other so when im looking for my button in ‘archive a task’ test case, I could effectively go ‘editTask’ + ‘taskID’?

any ideas?

You can only do it if you call TC1 then TC2 in the same execution. So TC1 must call TC2 or TC2 call TC1 before executing his own test.
Then you need to have a GlobalVariable with the correct type of the data you want to pass to the other TC.

You can assign a GlobalVariable like this :

GlobalVariable.[InsertGlobalVariableName] = value

You can use GlobalVariable.[InsertGlobalVariableName] as a normal variable in your other test case.

If your variable isn’t standard, like a custom class, you have to set null type to the GlobalVariable and cast the type when you get it in TC2, like :

CustomClass var = ((GlobalVariable.[InsertGlobalVariableName]) as CustomClass)

Good luck!