How to Pass a dynamic variable from one test suite to another?

I understand that you want to reuse “the Policy Number” in multiple Test Suites in a Test Suite Collection.

You chose a wrong path.

Two Test Suites in a TestSuiteCollection share nothing on memory. They can share only files on disk. TestSuiteA and TestSuiteB can not share anything on memory (e.g, a GlobalVariable value). So you should stop using Test Suite Collection. You should go for other ways of modularization.

Way 1: Test Cases in a Test Suite can share GlobalVariables

Let me assume a Test Suite includes 2 test cases, TestCase1 and TestCase2. So the TestCase1 can create a Policy Number and save it into a GlobalVariable.policyNumber; then the TestCase2 can refer to the GlobalVariable.policyNumber.

Way 2: Pass parameters via callTestCase() keyword

The callTestCase(calleeTestCase, params) keyword is more light-weight approach to share variable values. Your parent TestCaseC can call other Test Cases, TestCaseA and TestCaseB, while passing any value to the callees A and B. And a callee A can return any value to the caller TestCaseC.

1 Like