Same test case with different test data in excel

I have one test case let say TC1 and i have 2 different test data file let say TD1.xls and TD2.xls
I want to execute TC1 with TD1.xls and TD2.xls separately based on test suite.

For example let say i have 2 different test suite TS1 and TS2 and from them i want to call TC1 with TD1.xls and TD2.xls respectively.
How can i do this ?

Thanks in advance.

So if you are going to run them in different suites, its pretty straight forward. With the data binding just choose the data file you want it to use. So

If you want to do it in the same suite, just duplicate the test case and in the suit pick the other data file for it to bind with. So you will have TC1 with TD1 and then TC1(duplicate) with TD2. Now there is probably a better way of doing this but i havent looked into it. Have a read of the doc to make more sense.

You will need to import these:

import com.kms.katalon.core.configuration.RunConfiguration
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData

And then use RunConfiguration class to check for the Test Case name and choose which data source to use:

      TestData data = findTestData('TD1')
} else if (RunConfiguration.getExecutionSourceName()=="TC2") {
      TestData data = findTestData('TD2)
1 Like

Thanks for the reply.
I am not allowed to copy the TC1 and we can not bind different test data with same test case. Test case is single copy.

Can it be done dynamically, i mean i dont want to hardcode “TC1”, instead it will take the current test case name?

Exactly. getExecutionSourceName() will take the current test case name and you then compare it with whatever you want.

Hi it returns the current test suite, is there any way to get the current test case name/id?

Here, play with these options:

println RunConfiguration.getExecutionSource().substring(RunConfiguration.getExecutionSource().toString().lastIndexOf("\\")+1)
println RunConfiguration.getExecutionSourceName()
println RunConfiguration.executionSource
println RunConfiguration.getExecutionSourceId()
println RunConfiguration.getExecutionSourceDescription()

For all methods of the class, see:

Thank you, will let you know if done.

Tried with all option but not getting the test case file name while trying execute from the test suite level. Please help me know if any other option is available to get the test case name?

What does this line return:

println RunConfiguration.getExecutionSourceName()


It returns the Test suite name since i am executing it from the test suite level.

Using Test Listeners, i get the desired o/p.